1. Suppose you are given the following variable declarations: int x, y; char ch; What values (if any) are assigned to x, y, and ch after each of these statements execute? Assume that the input to each statement is the same: 5 28 36 a. cin >> x >> y >> ch; b. cin >> ch >> x >> y; c. cin >> x >> ch >> y; d. cin >> x >> y; cin.get(ch); a.x = 5 y = 28 ch = 3 b. x = 28 y = 36 z = 5 c.x = 5 y = 8 z = 2 d.x = 5 y = 28 z = ‘ ‘ (blank character) 2. Suppose you are given the following variable declarations: int x, y; char ch; What values (if any) are assigned to x, y, and ch after each of these statements execute? Assume that the input to each set of statements is as follows: 13 28 D 14 E 98 A B 56 a. cin >> x >> y; cin.ignore(50, ‘n’); cin >> ch; b. cin >> x; cin.ignore(50, ‘n’); cin >> y; cin.ignore(50, ‘n’); cin.get(ch); 3. Suppose you are given the following variable declarations: int x, y; double z; char ch; Assume you have the following input statement: cin >> x >> y >> ch >> z; What values (if any) are stored in x, y, z, and ch if the input is: a. 35 62. 78 b. 86 32A 92.6 c. 12 .45A 32 4. Write a C++ statement that uses the manipulator ‘setfill’ to output a line containing 35 asterisk characters. 5. What is the output from the following statements? a. if ( 60 <= 12 * 5) cout << “Hello”; cout << ” There”; b. if (‘a’ > ‘b’ || 66 > static_cast(‘A’)) cout << “#*#” << endl; c. if (7 <= 7) cout << 6 – 9 * 2 / 6 << endl; d. if (7 < 8) { cout << “2 4 6 8” << endl; cout << “1 3 5 7” << endl; } e. if (5 < 3) cout << “*”; else if (7 == 8) cout << “&”; else cout << “$”; 6. Suppose that you have the following variable declarations: int x = 10; int y = 15; int z = 20; Determine whether the following expressions are true or false. a. !(x < 10) b. x <= 5 || y > 15 c. (x != 5) && (y == z) d. x <= z && (x + y >= z) 7. What is the output of the following code fragment? int x = 100; int y = 200; if (x > 100 && y



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *