2. What is the output from the following C++ code fragment? int num = 1; while(n
ID: 3527126 • Letter: 2
Question
2. What is the output from the following C++ code fragment? int num = 1; while(num < 10) { cout << num << " "; num += 2; } cout << end; 3. What is the output from the following C++ code fragment if the following values are the inputs to cin? 38 35 71 14 -10 int sum, num; cin >> sum; for(int j = 1; j <= 3; j++) { cin >> num; sum += num; } cout << "Sum = " << sum << endl;Explanation / Answer
Return the modulo 25 of the input i.e. the remainer of the integer division. 58 = 2*25 + 8 => output = 8 23 = 0*25 + 23 => output = 23 75 = 3*25 + 0 => output = 0 176 = 25*7 + 1 => output = 1 145 = 25*5 + 20 => output = 20 -999 is just used to exit the loop thus output is 8 23 0 1 20 Faster to do it mentally in this case than to copy paste in the compiler ;-)
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.