+ 1

#include <iostream> using namespace std; int main() { int i=20,j=10; do {j+=i; i++;} while(j<=200); } how many times loops will run and output of "j"????

2nd Oct 2016, 6:21 PM
Omar Al Fahad
Omar Al Fahad - avatar
5 Answers
+ 2
the do while loop will loop 9 times, however it will never output the value of "j"
2nd Oct 2016, 9:01 PM
Michael Cottone
Michael Cottone - avatar
+ 1
9 loops for j=30, 51, 73, 96, 120, 145, 171, 198, 226. You have to count also 226 because the condition of the do..while is at the end of the loop. It doesn't give any output because there isn't any command to print the output, like "cout".
2nd Oct 2016, 11:23 PM
marcram
+ 1
it does not give any output beacuse there is no cout , or anyother output code
2nd Oct 2016, 11:26 PM
Michael Cottone
Michael Cottone - avatar
0
output 0 times.
2nd Oct 2016, 7:21 PM
Testing002
0
thanks@marcram
3rd Oct 2016, 1:50 AM
Omar Al Fahad
Omar Al Fahad - avatar