A

Admin • 833K Points
Coach

Q. What will be the output of this code?

Code:
void main()
{
int i=0;
for(;i++;printf("%d", i));
printf("%d", i);
}
  • (A) 1
  • (B) 11
  • (C) 12
  • (D) Error
  • Correct Answer - Option(A)
  • Views: 24
  • Filed under category C Programming
  • Hashtags:

Explanation by: Admin

Before entering into the for loop checking condition is "evaluated". Here it evaluates to 0 (false) and comes out of the loop, and i is incremented (note the semicolon after the for loop).

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.