Table of Content

Array MCQ : Guess the Output of Program (Multiple Choice Questions)


Question 1
Inner Block can access variables declared ___________.
A
inside Outer Block
B
inside Inner Block
C
inside Same Block
D
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);
}
A
Compile Time Error
B
10 20 10 20
C
10 20 10 garbage
D
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);
}
A
20 20 10 10
B
10 10 20 20
C
10 20 10 20
D
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 ?
A
None of these
B
Yes, It is possible
C
No , It will give compile error
D
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;
A
False
B
True
There are 5 questions to complete.