cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
test condition
test condition
Dec 14, 2009 at 2:48am UTC
cplusidiot
(9)
is the test-condition in a for statement is tested at the end of each pass? I am very confused on this topic. Thanks!
Dec 14, 2009 at 2:55am UTC
tummychow
(1210)
No, at the beginning of each pass. But the third section (the part where you usually put the ++ or --) is executed at the end of each pass if I am correct. (therefore, if the condition starts out false, the loop will never execute)
Dec 14, 2009 at 3:49am UTC
firedraco
(6243)
Yes a for loop like this:
1
2
3
for
(
int
i = 0; i < 10; ++i) {
//stuff
}
Is the same as:
1
2
3
4
5
6
7
{
int
i = 0;
while
(i < 10) {
//stuff
++i; } }
Topic archived. No new replies allowed.