Simple for loop question

1
2
3
4
5
for(c=-150;c<300;c+5)
{
                      //k=c+273.15;
                      cout<<c<<"       "<<endl;
}



For some reason, when I do this my compiler spams me with -150 on a never ending loop and doesn't seem to increase itself by 5.

When I take off the negative though, it works perfectly... I feel as though there is a simple fix but I don't know what is going on.


Edit: When I take the negative off as well I get spammed by the compiler with 150 as well.
Last edited on
you didn' tincrement c value at all
using c+5 has no effect
but c+=5 does
1
2
3
4
5
for(c=-150;c<300;c+=5)  //are you missing +=  ?
{
                      //k=c+273.15;
                      cout<<c<<"       "<<endl;
}
Last edited on
What a silly mistake :( Thank you!
Topic archived. No new replies allowed.