How many times does the following loop execute and why?
for (unsigned m = 5; --m >= 0; )
printf(“hello\n”);
it will run infinite time. beacuse the condition -- m>= 0 is always true . it is always true beacuse m is unsigned and it always return +ve value. .
4 byte unsigned value ranges from 0 to 4294967295
that means
unsigned 2 =2
unsigned 1 =1
unsigned 0 =0
unsigned -1 = 4294967295
unsigned -2 =4294967294
unsigned -3=4294967293
proof: -
Get Answers For Free
Most questions answered within 1 hours.