C | Loops & Control Structure | Question 6
#include <stdio.h> int main() { int i; if (printf("0")) i = 3; else i = 5; printf("%d", i); return 0; } |
chevron_right
filter_none
Predict the output of 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.
Recommended Posts:
- C | Loops & Control Structure | Question 1
- C | Loops & Control Structure | Question 9
- C | Loops & Control Structure | Question 2
- C | Loops & Control Structure | Question 3
- C | Loops & Control Structure | Question 4
- C | Loops & Control Structure | Question 5
- C | Loops & Control Structure | Question 16
- C | Loops & Control Structure | Question 18
- C | Loops & Control Structure | Question 17
- C | Loops & Control Structure | Question 7
- C | Loops & Control Structure | Question 19
- C | Loops & Control Structure | Question 20
- C | Loops & Control Structure | Question 10
- C | Loops & Control Structure | Question 21
- C | Loops & Control Structure | Question 8



