Try following example to understand for loop. You can put the following code into a test.c file and then compile it and then run it.
#include <stdio.h> main() { int i; int j = 10; for( i = 0; i <= j; i ++ ) { printf("NewFile. %d\n", i ); } }
Output:
NewFile. 0 NewFile. 1 NewFile. 2 NewFile. 3 NewFile. 4 NewFile. 5 NewFile. 6 NewFile. 7 NewFile. 8 NewFile. 9 NewFile. 10
You can make use of break to come out of for loop at any time.
#include <stdio.h> main() { int i; for( i = 0; i <= j; i ++ ) { printf("NewFile. %d\n", i ); if( i == 6 ) { break; } } }
NewFile. 1 NewFile. 2 NewFile. 3 NewFile. 4 NewFile. 5
Your Query was successfully sent!