hello everybody,
here i've one problem .can u guys please tell me what is output and *why?
main()
{
unsigned int i=10;
while(i>=0)
{
printf("%u\n",i);
i--;
}
}
thank u
srinu
with regards
Printable View
hello everybody,
here i've one problem .can u guys please tell me what is output and *why?
main()
{
unsigned int i=10;
while(i>=0)
{
printf("%u\n",i);
i--;
}
}
thank u
srinu
with regards
unsigned int always >= 0
So you get infinite loop.
change to signed int or modify your while ( condition )
I don't know how 0 is dealt with with respect to being signed or unsigned, but I would expect it to be a valid value for an unsigned int. IF it isn't, then you will get a never ending loop.
Otherwise the loop counts down from 10 to 0 inclusive by one stopping when i = -1, placing each new numeral on a new line using C style output.
As already said I believe, unsigned int i is always greater than or equal to 0, hence the infinite loop. The above is the first few lines of output.Code:10
9
8
7
6
5
4
3
2
1
0
4294967295
4294967294
4294967293
4294967292
dope slap to forehead.