This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Scope of a Variable – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the sequence of allocation and deletion of variables in the following C code?
#include <stdio.h>
int main()
{
int a;
{
int b;
}
}
a) a->b, a->b
b) a->b, b->a
c) b->a, a->b
d) b->a, b->a
View Answer
Explanation: None.
2. Array sizes are optional during array declaration by using ______ keyword.
a) auto
b) static
c) extern
d) register
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
void main()
{
int x = 3;
{
x = 4;
printf("%d", x);
}
}
a) 4
b) 3
c) 0
d) Undefined
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
int x = 5;
void main()
{
int x = 3;
m();
printf("%d", x);
}
void m()
{
x = 8;
n();
}
void n()
{
printf("%d", x);
}
a) 8 3
b) 3 8
c) 8 5
d) 5 3
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
int x;
void main()
{
m();
printf("%d", x);
}
void m()
{
x = 4;
}
a) 0
b) 4
c) Compile time error
d) Undefined
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
static int x = 5;
void main()
{
int x = 9;
{
x = 4;
}
printf("%d", x);
}
a) 9
b) 5
c) 4
d) 0
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
void main()
{
{
int x = 8;
}
printf("%d", x);
}
a) 8
b) 0
c) Undefined
d) Compile time error
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Apply for C Internship
- Practice Computer Science MCQs
- Apply for Computer Science Internship
- Buy Computer Science Books
- Buy C Books