I have tried following program in C language and the result of the program is:
Output : 0 is printed at last when the i
is unsigned int
, when the value of i
is 0, then the control should not go inside the while loop since I have given i>0
condition, but 0 is printed, I didn't understand how it is possible.
When the i
is signed int
, then 0 is not printed.
Please let me know what is happening in the program.
#include <stdio.h>
#include <string.h>
main()
{
unsigned int i=1;
int c=1;
while(i>0)
{
i=i*2;
c++;
printf("%d\n",i);
}
printf("%d c value is",c) ;
}