πŸ“Š C Programming
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
πŸ’¬ Discuss
βœ… Correct Answer: (A) 1

Explanation: 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).

Explanation by: Rajeev Malhotra
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).

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
167
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Rajeev Malhotra
Publisher
πŸ“ˆ
99%
Success Rate