C Programming - Declarations and Initializations - Discussion
Discussion Forum : Declarations and Initializations - Find Output of Program (Q.No. 6)
6.
What will be the output of the program?
#include<stdio.h>
int X=40;
int main()
{
int X=20;
printf("%d\n", X);
return 0;
}
Answer: Option
Explanation:
Whenever there is conflict between a local variable and global variable, the local variable gets priority.
Discussion:
21 comments Page 2 of 3.
Dipak said:
5 years ago
In function block, the local variable has the highest priority than global variable.
Vishwa said:
7 years ago
Can we use Upper case letters in declaring variables? Please explain me.
Savan said:
1 decade ago
If variable is declared globally, then it should be declared like X 40.
Abhishek said:
1 decade ago
Is it valid declaration? As we can not declare global auto variable.
Shivaleela said:
8 years ago
How can we print that global variable as output?
JITENDRA KUAMR said:
1 decade ago
How to access a global variable in C language?
Nishanth said:
8 years ago
Is we print that global variable as output?
Nihal said:
9 years ago
Local is preferred when there is conflict.
Vamshi said:
1 decade ago
What is local and global variables?
Sunitha said:
10 years ago
Here what's the use of return 0;?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers