Find the mistake(s) in the following code:
unsigned int i;
for (i = 100, i >= 0; --i)
printf("%d\n", i);
Unsigned integers cannot hold values that are less than 0 and so the exit condition of this for loop will never be met.
In addition, the format specifier %d
is for signed decimal integers and can be replaced with %u
assuming the resolution of the first issue does not involve changing the type of integer we are using in the iteration.