R

Rudra Pratap Singh • 3.39K Points
Extraordinary

Q. What is the output of the following C program?

Code:
#include <stdio.h>

int main()
{
    int main = 9;
    printf("%d", main);
    return 0;
}
  • (A) This will cause a compile error
  • (B) This will cause a runtime error
  • (C) It will run without error and displays 9
  • (D) It goes into an infinite loop

Explanation by: Rudra Pratap Singh
In a C program, you may encounter the same name of a function and the same name of a variable. The program will display:

$gcc prog3.c
$ a.out
9

You must be Logged in to update hint/solution

Discusssion

Login to discuss.


Question analytics