How many times does the loop iterate? int x = 3; while (x >
1) { --x;
}
a. 2 b. 0 c. 1 d. 3 e. infinite (the loop does not finish)
39. Given that vector<int> x has elements {34, 67, 3, 0, 78), what are the elements after the loop? Section ID: 328,116 ID: 5d84133e-8a61-35e7-ab2a-a141dc6a9552 int i; for (i = 0; i < x.size()-1; ++i) { x.at(i) = x.at(i + 1); Section ID: ID: ad658c80-02fd-42fa-aabc-fc996dab347f D. i <= 11 } A. 35, 69, 5, 4, 82 B. 67, 3, 0, 78, 78 C. 34, 68, 5, 3, 82 D. 34, 68, 5, 3, 79 E. 67, 3, 0, 78, 34 F. out of range error 40. Which condition causes the loop to iterate 10 times? 328,098 int i = 1; __) { while ( i=i+1; } A. i < 10 B. i> 10 C. i <= 10
35. What is the result of static_cast<double>((5 + 10)/2)? 328,071 A. 7 B. 8.0 C. 7.5 D. 7.0 36. What is output by the following code? Section ID: 328,103 ID: 8993cc53-b5e5-a656-5187-1a7e401a6207 int i = 0; do { cout << i << " "; ++i; } while (i < 0); a. 0 b. 0 1 c. syntax error d. Nothing 37. Given a vector of ints v and int variables x and i, what does this code output? x = 0; for (i = 0; i < v.size(); ++i) { if (v.at (i) >= x) { x = v.at(i); } } cout << x << endl; a. The maximum value in v c. The minimum value in v 38. What is the output? 328,108 vector<double> testScores (8); int i; for (i = 0; i < 6; ++i) { testScores.at (i) = 78.4; } testScores.at (i) = 97.2; ++i; testScores.at (i) = 87.5; --i; testScores.at (i) = 91.4; cout << testScores.at (7) << endl; a. 78.4 b. 87.5 c. 91.4 Section ID: d. 97.2 ID: db7d4183-29e1-4990-8840-3bdc3d919249 b. The maximum positive value in v, else 0 d. The minimum positive value in v, else 0 Section ID: ID: 993a2892-1818-07e1-e238-9972b49537b2
How many times does the loop iterate? int x = 3; while (x > 1) { --x; } a. 2 b. 0 c. 1 d. 3 e. infinite (the loop does n
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am