Question
Suppose that the input is 38 35 71 14 -1. What is the output of thefollowing code? Assume all variables are properly declared.sum = 0;cin >> num;while (num != -1){sum = sum + num;cin >> num;}cout << "Sum = " << sum << endl;
Step 1
Initialize the variable "sum" to 0. Show more…
Show all steps
Your feedback will help us improve your experience
Kumareshwaran Rathinasabapathy and 100 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
. Suppose that the input is 0 8 12 50 7 13 -1. What is the output of the following code? int num, sum, count; cin >> sum; cin >> count; cin >> num; while (count <= 4) { sum = sum + num; count++; cin >> num; } cout << "Sum = " << sum << endl;
What is the output of the following program? 10 Let $\mathrm{Sum}=0$ 20 Let $\mathrm{N}=8$ 30 if $\mathrm{N}<1$ then Go to 70 40 Let Sum $=$ Sum $+\mathrm{N} * \mathrm{~N}$ 50 Let $\mathrm{N}=\mathrm{N}-2$ 60 Go to 30 70 Print Sum 80 end (1) 120 (2) 125 (3) 145 (4) 170
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD