main()
{
signed char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
}
Answer
-128
Explanation
Notice the semicolon at the
end of the for loop. THe initial value of the i is set to 0. The inner loop
executes to increment the value from 0 to 127 (the positive range of char) and
then it rotates to the negative value of -128. The condition in the for loop
fails and so comes out of the for loop. It prints the current value of i that
is -128.
Blog Author: Vijay Kumar
No comments:
Post a Comment