Pick your favorite computer language and write a small program. After compiling the program, see if you can determine the ratio of source code instructions to the machine language instructions generated by the compiler. If you add one line of source code, how does that affect the machine language program? Try adding different source code instructions, such as an add and then a multiply. How does the size of the machine code file change with the different instructions? Comment on the result.
I choosed C++ computer language. Take an add and multiplication program code in C++ is as follows:
#include <iostream>
using namespace std;
int main() {
int a = 5;
int b = 3;
int sum;
int product;
// Addition
sum = a + b;
cout << "Sum: " << sum << std::endl;
// Multiplication
product = a * b;
cout << "Product: " << product << std::endl;
return 0;
}
Executed Output:
Sum: 8
Product: 15
Explanation:
Now, regarding the question about the ratio of source code instructions to machine language instructions, it's important to note that the exact ratio will depend on the specific C++ compiler and optimization settings used.