Game with Printf()

What is the output of the following C program?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
#include <stdio.h>

int main()
{
    int d = 123;

    if(printf(""))
        printf("%d", d);
    else
        printf("%d", 1);

    return 0;
} 

1 Compilation Error Runtime Error 123

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Deepak Mourya
Apr 18, 2016

printf() function in C returns how many character you print. In above case we don't print any character so our if condition is false so our program will print 1.(which is in false condition)

The best solution: 1. Download C 2. Copy/paste the code 3. Click run :)

Josiah Kiok - 4 years, 6 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...