I want to ask, what is the difference between these two cases?
Option 1:
unsigned int i;
for(i=10;i>=0;i--)
printf("%d",i);
This will lead to an endless loop!
Case 2:
unsigned int a=-5;
printf("%d",a);
It will display -5 on the screen.
Now the reason for case 1 is that it is ideclared as unsigned int, therefore it cannot take negative values , therefore it will always be greater than 0.
But in case 2, if ait cannot take negative values, why is -5 printed ???
What is the difference between these two cases?
source
share