Logo 
Search:

C Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C ProgrammingRSS Feeds

C programming practical question 134

  Shared By: Adah Miller    Date: Jan 24    Category: C Programming    Views: 59

Answer:

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.

Share: 
 

Didn't find what you were looking for? Find more on C programming practical question 134 Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: