Sail E0 Webinar
Question


What is the output of the program?


#include<stdio.h>
int main ()
{
extern int a;
printf ("%d\n", a);
}
int a = 20;
Options:
A .  20
B .  0
C .  Garbage Value
D .  Error
Answer: Option A

extern int a; indicates that the variable a is defined elsewhere, usually in a 

separate source code module.

printf("%d`setminus`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.




Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers