The program below has a bug. Which statement correctly describes it?
#include <stdio.h>
int main(void) {
int a[3] = {1, 2, 3};
for (unsigned i = 2; i >= 0; i--)
printf("%d ", a[i]);
printf("\n");
return 0;
}
Unsigned values cannot be negative, so the loop never ends by itself; the next index after 0 is UINT_MAX and the read crashes. Write for (unsigned i = 3; i-- > 0; ).