C Programming MCQ : Switch Case Multiple Choice Questions
Question 1 |
Higher priority is given to ________ variable than _______ variable.
Global , Local | |
Local , Global |
Question 2 |
Inner Block can access variables declared ___________.
inside Outer Block | |
inside Inner Block | |
None of these | |
inside Same Block |
Question 2 Explanation:
Inner Block can access variables declared inside Outer Block.
Question 3 |
What will be the output of the following program ?
#include<stdio.h> void main() { int var1=10; { int var2 = 20; printf("%d %d",var1,var2); } printf("%d %d",var1,var2); }
10 20 10 garbage | |
Compile Time Error | |
10 20 10 20 | |
Run Time Error |
Question 3 Explanation:
Outer block can’t access variables declared inside Inner Block.
Question 4 |
Guess output of program -
#include<stdio.h> void main() { int var1=10; { int var1 = 20; printf("%d %d",var1,var1); } printf("%d %d",var1,var1); }
20 10 20 10 | |
10 20 10 20 | |
10 10 20 20 | |
20 20 10 10 |
Question 4 Explanation:
If same variable is declared inside inner as well as outer block then higher priority will be given to inner block.
Question 5 |
Can we declare same variable inside the inner and outer block ?
No , It will give compile error | |
None of these | |
Duplicate Variable is not allowed in C Program | |
Yes, It is possible |
There are 5 questions to complete.