answersLogoWhite

0

How do you use for loop in c?

User Avatar

Anonymous

13y ago
Updated: 8/19/2019

The for loop in C, and C++ and Java, is defined as ...

for (init-expression, limit-expression, loop-expression) statement;

The init-expression is evaluated once. Then the limit-expression is evaluated. If it is true, the statement is evaluated, which can be a block of statements, or even a null statement, otherwise, control transfers out of the loop. If the statement is executed, then the loop-expression is evaluated, and control transfers back to the limit-expression.

As an example, to print the numbers 1 through 10 ...

for (int i = 1; i <= 10; ++i) printf ("%d\n", i);

User Avatar

Wiki User

13y ago

What else can I help you with?