This shows you the differences between two versions of the page.
|
c:control_structures:for [2013/01/17 23:47] Daniel Gohlke created |
c:control_structures:for [2024/02/16 01:04] (current) |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | {{keywords>wiki library source code example reference}} | ||
| + | ===== for ===== | ||
| + | <code c> | ||
| + | #include <stdio.h> /* including standard library */ | ||
| + | //#include <windows.h> /* uncomment this for Windows */ | ||
| + | |||
| + | for ( init; condition; increment ){ | ||
| + | statements; | ||
| + | } | ||
| + | </code> | ||
| + | ===== C Sourcecode Example ===== | ||
| + | |||
| + | <code c> | ||
| + | #include <stdio.h> /* including standard library */ | ||
| + | //#include <windows.h> /* uncomment this for Windows */ | ||
| + | |||
| + | int main( void ) | ||
| + | { | ||
| + | int i; | ||
| + | for (i=0;i<=42;i++){ | ||
| + | |||
| + | printf("i is : %i\n",i); | ||
| + | } | ||
| + | |||
| + | return 0; | ||
| + | } | ||
| + | |||
| + | </code> | ||
| + | |||
| + | output of for loop | ||
| + | i is : 0 | ||
| + | i is : 1 | ||
| + | i is : 2 | ||
| + | i is : 3 | ||
| + | and so on | ||