Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

C | Loops & Control Structure | Question 6

  • Difficulty Level : Easy
  • Last Updated : 15 Jan, 2013

Take a step-up from those "Hello World" programs. Learn to implement data structures like Heap, Stacks, Linked List and many more! Check out our Data Structures in C course to start learning today.

#include <stdio.h>
int main()
    int i;
    if (printf("0"))
        i = 3;
        i = 5;
    printf("%d", i);
    return 0;

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.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!