I want to ask what is the difference between these two cases ?
Case1:
unsigned int i;
for(i=10;i>=0;i--)
printf("%d",i);
It will result in an infinite loop!
Case2:
unsigned int a=-5;
printf("%d",a);
It will print -5 on the screen.
Now the reason for case 1 is that i
is declared as unsigned int
so it can not take negative values,hence will always be greater than 0.
But in case 2, if a
cannot take negative values, why -5 is being printed???
What is the difference between these two cases?