Declarations and Initializations

Q1:
What is the output of the program?
#include<stdio.h>
int main()
{
    extern int a;
    printf('%d\n', a);
    return 0;
}
int a=20;

A 20

B 0

C Garbage Value

D Error

ANS:A - 20

extern int a; indicates that the variable a is defined elsewhere, usually in a separate source code module. printf('%d\n', a); it prints the value of local variable int a = 20. Because, whenever there is a conflict between local variable and global variable, local variable gets the highest priority. So it prints 20.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.