Last Updated :
10 Apr, 2024
#include <iostream>
using namespace std;
int main()
{
int i;
if (printf(\"0\"))
i = 3;
else
i = 5;
cout << i;
return 0;
}
Predict the output of the above program
(A) 3
(B) 5
(C) 03
(D) 05
Answer: (C)
Explanation: The control first goes to the if statement where 0 is printed. The printf(“0”) returns the number of characters being printed i.e. 1. The block under if statement gets executed and i is initialized with 3.
Share your thoughts in the comments
Please Login to comment...