Array MCQ : Guess the Output of Program (Multiple Choice Questions)
Question 1 |
Inner Block can access variables declared ___________.
inside Outer Block | |
inside Inner Block | |
inside Same Block | |
None of these |
Question 1 Explanation:
Inner Block can access variables declared inside Outer Block.
Question 2 |
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); }
Compile Time Error | |
10 20 10 20 | |
10 20 10 garbage | |
Run Time Error |
Question 2 Explanation:
Outer block can’t access variables declared inside Inner Block.
Question 3 |
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 20 10 10 | |
10 10 20 20 | |
10 20 10 20 | |
20 10 20 10 |
Question 3 Explanation:
If same variable is declared inside inner as well as outer block then higher priority will be given to inner block.
Question 4 |
Can we declare same variable inside the inner and outer block ?
None of these | |
Yes, It is possible | |
No , It will give compile error | |
Duplicate Variable is not allowed in C Program |
Question 5 |
In order to create a local variable we need to use local keyword.
local int var;
False | |
True |
There are 5 questions to complete.