for LOOP : For statement « Statement « C Tutorial

C Tutorial
1. Language
2. Data Type
3. String
4. printf scanf
5. Operator
6. Statement
7. Array
8. Function
9. Structure
10. Pointer
11. Memory
12. Preprocessor
13. File
14. Data Structure
15. Search Sort
16. Wide Character String
17. assert.h
18. ctype.h
19. math.h
20. setjmp.h
21. signal.h
22. stdio.h
23. stdlib.h
24. string.h
25. time.h
26. wctype.h
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
C Tutorial » Statement » For statement 
6. 6. 1. for LOOP

The for loop is usually used when the number of iterations is predetermined.

The format of the for loop is

for (expr1;expr2;expr3){
        s1;
        s2 ;
    }
  1. expr1 is executed only once before looping.
  2. expr2 is a Boolean expression. If not given, it is assumed to be true.
  3. If expr2 is false, the loop is terminated.
  4. After execution of the repeat section, expr3 is executed
  5. The expressions expr1, expr2 and expr3 are all optional.
#include <stdio.h>

main(){
    int i,n = 5;
   
    for(i = 0; i < n; i = i+1){
       printf("the numbers are %d \n",i);
    }
}
the numbers are 0
     the numbers are 1
     the numbers are 2
     the numbers are 3
     the numbers are 4
6. 6. For statement
6. 6. 1. for LOOP
6. 6. 2. Omit all three parts in for loop
6. 6. 3. The for loop with a comma operator
6. 6. 4. Initialize loop control variable outside the for statement
6. 6. 5. Use for loop to print a rectangle
6. 6. 6. Sum integers in for statement
6. 6. 7. for loop backward
6. 6. 8. indefinite loop: empty for
6. 6. 9. Nest if statement in for loop
6. 6. 10. Nest for loop: two different control variables
6. 6. 11. Use char variable to control for loop
6. 6. 12. Continue a for loop
w_ww_.j_a___v___a__2s___.__c_om | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.