#include <stdio.h>
void main()
{
unsigned int i;
for(i=1;i>-2;i--)
printf("c aptitude");
}
Output:
ConCept:
No Output, because when the compiler encounters the statement 'i > -2', something happens that is unusual for a beginner coder mind. Here i is unsigned, so -2 is also made to jump in the unsigned region. The range of unsigned int (32 bit compiler) is 2^32 - 1 (that will be the value of (unsigned)-1), so the value of -2 will be 2^32 - 2. Rest you can analyze on you own.
void main()
{
unsigned int i;
for(i=1;i>-2;i--)
printf("c aptitude");
}
Output:
ConCept:
No Output, because when the compiler encounters the statement 'i > -2', something happens that is unusual for a beginner coder mind. Here i is unsigned, so -2 is also made to jump in the unsigned region. The range of unsigned int (32 bit compiler) is 2^32 - 1 (that will be the value of (unsigned)-1), so the value of -2 will be 2^32 - 2. Rest you can analyze on you own.
No comments:
Post a Comment