206k views
0 votes
Which is an example of a valid “for” statement?

a) for(int i = 0 ; i < 5 ; i++)

b) for(string i ; i = 0 ; i++)

c) for(char i = 0 ; i < 8 ; j++)

User Mustafabar
by
4.8k points

1 Answer

4 votes

Answer:

a) for(int i = 0 ; i < 5 ; i++)

Step-by-step explanation:

a) for(int i = 0 ; i < 5 ; i++) is a valid for statement.

It makes use of an integer variable i which initializes to 0. Then the loop condition (i<5) is evaluated to verify that it is true.

After this loop body is executed. At the end of the body, loop variable is incremented by 1 and next iteration of loop commences. This process continues till loop condition becomes false at which point the loop terminates.

User Meylin
by
5.4k points