This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Static 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();
m();
}
void m()
{
static int x = 5;
x++;
printf("%d", x);
}
a) 6 7
b) 6 6
c) 5 5
d) 5 6
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
void main()
{
static int x;
printf("x is %d", x);
}
a) 0
b) 1
c) Junk value
d) Run time error
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
static int x;
void main()
{
int x;
printf("x is %d", x);
}
a) 0
b) Junkvalue
c) Run time error
d) Nothing
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
void main()
{
static double x;
int x;
printf("x is %d", x);
}
a) Nothing
b) 0
c) Compile time error
d) Junkvalue
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
void main()
{
static int x;
if (x++ < 2)
main();
}
a) Infinite calls to main
b) Run time error
c) Varies
d) main is called twice
View Answer
Explanation: None.
6. Which of following is not accepted in C?
a) static a = 10; //static as
b) static int func (int); //parameter as static
c) static static int a; //a static variable prefixed with static
d) all of the mentioned
View Answer
Explanation: None.
7. Which of the following cannot be static in C?
a) Variables
b) Functions
c) Structures
d) None of the mentioned
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.
- Check C Books
- Practice BCA MCQs
- Practice Computer Science MCQs
- Watch Advanced C Programming Videos
- Check Computer Science Books