66.7k views
1 vote
What will the following code fragment print?

for (i = 0; i < 9; i++);

cout << i + 1;

cout << i;

User Saggex
by
7.0k points

1 Answer

5 votes

Answer:

This code will print 109.

Step-by-step explanation:

Condition is the integer i is declared before the loop then the code will print 109. 10 because of the statement cout<<i+1; and 9 because of the cout<<i; . The for loop starts with 0 and ends when the value of i becomes 9. Since there is semi-colon after the for loop so the next statement after the for loop is not included in the loop.

User Alex Jj
by
6.8k points