for loop until 0
Aug 12, 2014 at 6:26am
how can I write the code to loop the a value to 0 without using signed int?
I try ==0, but it doesn't work
|
for(signed int a=10;a>-1;a--)
|
Aug 12, 2014 at 6:49am
|
for (unsigned int a = 10; a <= 10; a--)
|
This works because when an unsigned number is decremented below zero it wraps around and becomes the largest possible value.
Aug 12, 2014 at 6:49am
Last edited on Aug 12, 2014 at 6:49am
Aug 12, 2014 at 6:54am
i think you are confusing about looping
1 2
|
int a=0;
for(;a>=0;a--)
|
Aug 12, 2014 at 6:59am
thx
Topic archived. No new replies allowed.