Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Problem 11

include using namespace… # In the following program, number the marked statements to show the order in which they will execute (the logical order of execution). #include using namespace std; void func(int val1, int val2); int main() { int num1, num2; ___ cout << "Please enter two integers." << endl; ___ cin >> num1 >> num2; ___ func (num1, num2); ___ cout << " The two integers are " << num1 << ", " << num2 << endl; ___ return 0; } void func(int val1, int val2) { int val3, val4; ___ val3 = val1 + val2; ___ val4 = val1 * val2; ___ cout << "The sum and product are " << val3 << " and " << val4 << endl; }

Problem 15

What is the output of the following code fragment? (Note: alpha and beta are int variables.) alpha = 5; beta = 10; if (beta >= 10) { int alpha = 10; beta = beta + alpha; cout << alpha << ' ' << beta << endl; } cout << alpha << ' ' << beta << endl;

Problem 16

include using namespa… # Consider the following program. What is its exact output? Show the values of the variables after each line executes, as in Example 7-6. #include using namespace std; void funOne(int& a); int main() { int num1, num2; num1 = 10; //Line 1 num2 = 20; //Line 2 cout << "Line 3: In main: num1 = " << num1 << ", num2 = " << num2 << endl; //Line 3 funOne(num1); //Line 4 cout << "Line 5: In main after funOne: num1 = " << num1 << ", num2 = " << num2 << endl; //Line 5 return 0; //Line 6 } void funOne(int& a) { int x = 12; int z; z = a + x; //Line 7 cout << "Line 8: In funOne: a = " << a << ", x = " << x << ", and z = " << z << endl; //Line 8 x = x + 5; //Line 9 cout << "Line 10: In funOne: a = " << a << ", x = " << x << ", and z = " << z << endl; //Line 10 a = a + 8; //Line 11 cout << "Line 12: In funOne: a = " << a << ", x = " << x << ", and z = " << z << endl; //Line 12 }

Problem 17

include using namespace std; void tryMe(int& v); int main() { int x = 8; for (int count = 1; count < 5; count++)… # What is the output of the following program? #include using namespace std; void tryMe(int& v); int main() { int x = 8; for (int count = 1; count < 5; count++) tryMe(x); return 0; } void tryMe(int& v) { static int num = 2; if (v % 2 == 0) { num++; v = v + 3; } else { num--; v = v + 5; } cout << v << ", " << num << endl; }

Problem 20

Consider the following function definition: void defaultParam(int u, int v = 5, double z = 3.2) { int a; u = u + static_cast(2 * v + z); a = u + v * z; cout << "a = " << a << endl; } What is the output of the following function calls? a. defaultParam(6); b. defaultParam(3, 4); c. defaultParam(3, 0, 2.8);

Access millions of textbook solutions in one place

  • Access over 3 million high quality textbook solutions
  • Access our popular flashcard, quiz, mock-exam and notes features
  • Access our smart AI features to upgrade your learning
Get Vaia Premium now
Access millions of textbook solutions in one place

Recommended explanations on Computer Science Textbooks