Discussion :: Control Instructions
-
What will be the output of the program, if a short int is 2 bytes wide?
#include
Answer : Option A
Explanation :
for(i=-1; ++i; i>0) so expression i=-1 initializes for loop. expression ++i is the loop condition. expression i>0 is the increment expression.
In for( i = -1; ++i; i>0) expression i=-1 evaluates to one.
Loop condition always get evaluated to true. Also at this point it increases i by one.
An increment_expression i>0 has no effect on value of i.so for loop get executed till the limit of integer (ie. 65535)
Be The First To Comment