C Programming - Declarations and Initializations - Discussion
Discussion Forum : Declarations and Initializations - Find Output of Program (Q.No. 12)
12.
What will be the output of the program?
#include<stdio.h>
int main()
{
int X=40;
{
int X=20;
printf("%d ", X);
}
printf("%d\n", X);
return 0;
}
Answer: Option
Explanation:
In case of a conflict between a local variable and global variable, the local variable gets priority.
Discussion:
22 comments Page 3 of 3.
Suryakanta said:
7 years ago
C programming does not support the blocks so it will not return the error.
Adipto said:
6 years ago
Initially the value of x is 40, then it is changed to 20. How come x again gets the value 40? Please explain it in detail.
(1)
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers