1. When you are using %u, it is for unsigned printing. 2. looking at the loop, it will run for only values of i for(i<=5 && i>=-1;++i;i>0) ^^ the first statement here is not the conditional one.
3. since int is of 4 bytes on your system, the max positive value it will print is power(2, 32) - 1. (4 bytes = 32 bits) if suppose you used unsigned int, then that would have been an infinite loop. since the condition is i>=-1. each time you incremented the value of i , it would have been between (0, 2^64-1) only. On 2 August 2011 03:16, Dharmendra Modi <[email protected]>wrote: > The first part initialization of for loop (i<=5 && i>=-1) is just an > initialization and nothing else. It is of no use in this case. > > The second part condition holds the condition which is in this case + > +i specifying to run loop till i is non zero. You are using prefix > operator hence it will first increment i and then test. > If you have used i++ the loop wont even have executed single time. > > The condition ++i becomes zero when there is round of short and you > get zero at that time the loop terminates. > > The format specifier for unsigned int is used hence positive values > are printed. > If the format specifier for %d is used then the results would be more > informative. > > Hope that helps. > > On Aug 1, 11:51 pm, jagrati verma <[email protected]> wrote: > > #include<stdio.h> > > main() > > { > > short int i=0; > > for(i<=5 && i>=-1;++i;i>0) > > printf("%u\n",i); > > printf("\n"); > > return 0;} > > > > o/p is 1..... > > 4294967295 hw??????????????????????????? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- ___________________________________________________________________________________________________________ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers <=> Save Trees -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
