Tuesday 26 March 2013

(i>2)?i++:i--;


    void main()
{
static int i;
while(i<=10)
(i>2)?i++:i--;
    printf(“%d”, i);
}
Answer:
         32767
Explanation:
Since i is static it is initialized to 0. Inside the while loop the conditional operator evaluates to false, executing i--. This continues till the integer value rotates to positive value (32767). The while condition becomes false and hence, comes out of the while loop, printing the i value.

Blog Author: Vijay Kumar

No comments:

Post a Comment