Switch to full style
C++ code examples
Post a reply

C++ For Loops

Thu Nov 13, 2008 1:57 pm

The for statement is similar to Java's.

Abbreviates a while loop.
cpp code
for(init;test;incr)stmt
Abbreviates...
init;while(test){stmt incr;}

for(i = 1; i <= 10; ++i) printf("%d\n", i);
Abbreviates...
i = i; while(i <= 10) { printf("%d\n", i); ++i; }


Pure C forbade declarations in for loops until C99. Many compilers will still forbid. it.



Post a reply
  Related Posts  to : C++ For Loops
 C++ for loops     -  
 Loops and Branching     -  
 Nesting Two for Loops     -  
 Break in Nested Loops     -  
 Re: Lets Learn C++----->(Lesson 4) Loops     -  
 write a while loops performing operations on number     -  
 Using Program Loops to Create Time Delays     -  

Topic Tags

C++ Loops