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
loop question
loop question
Jul 27, 2011 at 6:18pm UTC
costaaa
(18)
What are the values of i and n after this loop executes?
int n = 0;
for(int i = 1; i <= 8; i++) {
n = n + (i % 2);
}
Jul 27, 2011 at 11:35pm UTC
jsmith
(5804)
This isn't a hard question. You won't learn anything if we just give you the answer. Get out a pencil and paper, and write down the values of i and n each time through the loop.
Jul 28, 2011 at 2:15am UTC
Turbine
(134)
Or you could just print it out.. A pretty obvious way to tell. Either way you can figure it out in your head.
Topic archived. No new replies allowed.