This set of C Multiple Choice Questions & Answers (MCQs) focuses on “External Variables – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the output of the following C code?
#include <stdio.h>
void main()
{
m();
printf("%d", x);
}
int x;
void m()
{
x = 4;
}
a) 4
b) Compile time error
c) 0
d) Undefined
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
int x;
void main()
{
printf("%d", x);
}
a) Junk value
b) Run time error
c) 0
d) Undefined
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
int x = 5;
void main()
{
int x = 3;
printf("%d", x);
{
x = 4;
}
printf("%d", x);
}
a) Run time error
b) 3 3
c) 3 5
d) 3 4
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;
printf("%d", x);
{
int x = 4;
}
printf("%d", x);
}
a) 3 3
b) 3 4
c) 3 5
d) Run time error
View Answer
Explanation: None.
5. Functions in C are always _________
a) Internal
b) External
c) Both Internal and External
d) External and Internal are not valid terms for functions
View Answer
Explanation: None.
6. Global variables are ____________
a) Internal
b) External
c) Both Internal and External
d) None of the mentioned
View Answer
Explanation: None.
7. Which of the following is an external variable in the following C code?
#include <stdio.h>
int func (int a)
{
int b;
return b;
}
int main()
{
int c;
func (c);
}
int d;
a) a
b) b
c) c
d) d
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
int main()
{
printf("%d", d++);
}
int d = 10;
a) 9
b) 10
c) 11
d) Compile time error
View Answer
Explanation: None.
9. What will be the output of the following C code?
#include <stdio.h>
double var = 8;
int main()
{
int var = 5;
printf("%d", var);
}
a) 5
b) 8
c) Compile time error due to wrong format identifier for double
d) Compile time error due to redeclaration of variable with same name
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.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]
- Check C Books
- Check Computer Science Books
- Practice Computer Science MCQs
- Watch Advanced C Programming Videos
- Practice BCA MCQs