Chapter 5: Problem 11
include
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.
/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none}
Learning Materials
Features
Discover
Chapter 5: Problem 11
include
These are the key concepts you need to understand to accurately answer the question.
All the tools & learning materials you need for study success - in one app.
Get started for free
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;
How many times will each of the following loops execute? What is the output in each case? a. x = 5; y = 50; do x = x + 10; while (x < y); cout << x << " " << y << endl; b. x = 5; y = 80; do x = x * 2; while (x < y); cout << x << " " << y << endl; c. x = 5; y = 20; do x = x + 2; while (x >= y); cout << x << " " << y << endl; d. x = 5; y = 35; while (x < y) x = x + 10; cout << x << " " << y << endl; e. x = 5; y = 30; while (x <= y) x = x * 2; cout << x << " " << y << endl; f. x = 5; y = 30; while (x > y) x = x + 2; cout << x << " " << y << endl;
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;
Rewrite the following as a for loop. int i = 0, value = 0; while (i <= 20) { if (i % 2 == 0 && i <= 10) value = value + i * i; else if (i % 2 == 0 && i > 10) value = value + i; else value = value - i; i = i + 1; } cout << "value = " << value << endl; What is the output of this loop?
What is the output of the following program segment? int count = 5; while (count-- > 0) cout << count << " "; cout << endl;
What do you think about this solution?
We value your feedback to improve our textbook solutions.