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 1

Mark the following statements as true or false. a. In a counter-controlled while loop, it is not necessary to initialize the loop control variable. b. It is possible that the body of a while loop may not execute at all. c. In an infinite while loop, the while expression (the decision maker) is initially false, but after the first iteration it is always true. d. The while loop: j = 0; while (j <= 10) j++; terminates if j > 10. e. A sentinel-controlled while loop is an event-controlled while loop whose termination depends on a special value. f. \(\quad\) A loop is a control structure that causes certain statements to execute over and over. g. To read data from a file of an unspecified length, an EOF-controlled loop is a good choice. h. When a while loop terminates, the control first goes back to the statement just before the while statement, and then the control goes to the statement immediately following the while loop.

Problem 2

. What is the output of the following C++ code? int count = 1; int y = 100; while (count < 100) { y = y - 1; count++; } cout << " y = " << y << " and count = " << count << endl;

Problem 3

What is the output of the following C++ code? int num = 5; while (num > 5) num = num + 2; cout << num << endl;

Problem 4

What is the output of the following C++ code? int num = 1; while (num < 10) { cout << num << " "; num = num + 2; } cout << endl;

Problem 5

When does the following while loop terminate? ch = 'D'; while ('A' <= ch && ch <= 'Z') ch = static_cast(static_cast(ch) + 1);

Problem 6

Suppose that the input is 38 35 71 14 -1. What is the output of the following code? Assume all variables are properly declared. cin >> sum; cin >> num; for (j = 1; j <= 3; j++) { cin >> num; sum = sum + num; } cout << "Sum = " << sum << endl;

Problem 7

Suppose that the input is 38 35 71 14 -1. What is the output of the following code? Assume all variables are properly declared. cin >> sum; cin >> num; while (num != -1) sum = sum + num; cin >> num; } cout << "Sum = " << sum << endl;

Problem 8

Suppose that the input is 38 35 71 14 -1. What is the output of the following code? Assume all variables are properly declared. cin >> num; sum = num; while (num != -1) { cin >> num; sum = sum + num; } cout << "Sum = " << sum << endl;

Problem 9

Suppose that the input is 38 35 71 14 -1. What is the output of the following code? Assume all variables are properly declared. sum = 0; cin >> num; while (num != -1) { sum = sum + num; cin >> num; } cout << "Sum = " << sum << endl;

Problem 11

include using namespace std; int main() { int x, y, z; x = 4; y = 5; z = y + 6; while(((z - x) % 4) != 0) { cout… # What is the output of the following program? #include using namespace std; int main() { int x, y, z; x = 4; y = 5; z = y + 6; while(((z - x) % 4) != 0) { cout << z << " "; z = z + 7; } cout << endl; return 0; }

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