10. Variable Scoping MCQ
Variable Scoping Question 1
int i;
for (i = 0;i < 5; i++)
int a = i;
printf("%d", a);
Variable Scoping Question 2
Which variable has the longest scope?
#include <stdio.h>
int b;
int main()
{
int c;
return 0;
}
int a;
Variable Scoping Question 3
Choose the correct option
#include <stdio.h> //Program 1
int main()
{
int a;
int b;
int c;
}
#include <stdio.h> //Program 2
int main()
{
int a;
{
int b;
}
{
int c;
}
}
Both are same
Scope of c is till the end of the main function in Program 2
In Program 1, variables a, b and c can be used anywhere in the main function whereas in Program 2, variables b and c can be used only inside their respective blocks
None of the mentioned
Last updated