1.(20 points) What output will the following code fragments produce? Provide the answers exactly as the output.
(a)num = 10; x = 5; cout << num << " "; cout << x << " "; cout << endl; cout << num << endl;
10 5 10
x = 4; y = 14; y = y + x; x = x + 1; cout << "x = " << x << '\n'; cout << "y = " << y << '\n';
x = 5 y = 18
/************************ * first.cpp * My First C++ file * July 18, 2005 *************************/ main() { int num1; int 2ndNum = 3; cout >> 'Can I make it all right? \n' num1 = 11; num_3 = 2ndNum; cout >> num1 >> " " >> 2ndNum >> " " >> num3 >> "\n"; }
/************************ * first.cpp * My First C++ file * July 18, 2005 *************************/ #include <iostream> using namespace std; int main() { int num1; int SecondNum = 3; int num_3 = 0; cout << "Can I make it all right? \n"; num1 = 11; num_3 = SecondNum; cout << num1 << " " << SecondNum << " " << num_3 << '\n'; return 0; }
Compile and run your program, Correct any errors you have made.
Submit the final program fulfilling all the requirements, and also the output.
Answer:/************************ * Question 3, Assignment 1 * * July 18, 2005 *************************/ #include <iostream> using namespace std; int main() { const int A = 1; const float B = 2.2; int C; float D; float E = 3.32, F = 4.45, G = 6.61; unsigned short age = 11; C = A; D = B; cout << "C = " << C << endl; cout << "D = " << D << endl; cout << "E = " << E << ", " << "F = " << F << ", " << "G = " << G << endl; cout << "My nephew Jeremey is " << age << " years old." << endl; return 0; }