cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
while loop
while loop
Oct 25, 2014 at 1:54pm UTC
Droid
(1)
//Print every odd number descending from 39
int y = 0;
while(y <= 39){
cout << y;
y = (y - 2);// Take two from y after every loop
}
How do I stop the loop
Last edited on
Oct 25, 2014 at 1:56pm UTC
Oct 25, 2014 at 2:55pm UTC
wildblue
(1505)
You're initializing y to 0, but it looks like you want to initialize to 39 and then count down from there in the loop, stopping when you reach 0. So while y is greater than 0, you want to keep running the loop.
Topic archived. No new replies allowed.