1. What will be the output of the following C code?
-
#include
-
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
Answer: a
Clarification: None.
2. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
static int x;
-
printf("x is %d", x);
-
}
a) 0
b) 1
c) Junk value
d) Run time error
Answer: a
Clarification: None.
3. What will be the output of the following C code?
-
#include
-
static int x;
-
void main()
-
{
-
int x;
-
printf("x is %d", x);
-
}
a) 0
b) Junkvalue
c) Run time error
d) Nothing
Answer: b
Clarification: None.
4. What will be the output of the following C code?
-
#include
-
void main()
-
{
-
static double x;
-
int x;
-
printf("x is %d", x);
-
}
a) Nothing
b) 0
c) Compile time error
d) Junkvalue
Answer: c
Clarification: None.
5. What will be the output of the following C code?
-
#include
-
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
Answer: d
Clarification: 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
Answer: c
Clarification: None.
7. Which of the following cannot be static in C?
a) Variables
b) Functions
c) Structures
d) None of the mentioned
Answer: d
Clarification: None.