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
For Loops
For Loops
Oct 7, 2015 at 5:27am UTC
b29hockey
(60)
So i am trying to get a variable starting at 0, to increase by 30 until 360. But im having some real trouble. What am i doing wrong? this is my first time working with loops. Any help would be appreciated.
for (degree; degree <= 360; degree + 30) {
cout << degree << endl;
}
This just gives me an endless loop of 0's.
Oct 7, 2015 at 5:34am UTC
firedraco
(6243)
You are adding 30 to degree in the increment step, but you aren't assigning it to anywhere.
1
2
3
for
(degree; degree <= 360; degree += 30) {
//use += instead
cout << degree << endl; }
Oct 7, 2015 at 5:38am UTC
b29hockey
(60)
Thank You!!! I knew it was something simple that i missed!
Topic archived. No new replies allowed.