1. 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
Discussion
2. 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
Discussion
3. 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
Discussion
4. 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
Discussion
5. 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
Discussion
6. 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
Discussion
7. 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
Discussion
8. Which of the following cannot be static in C?
a) Variables
b) Functions
c) Structures
d) None of the mentioned
Discussion
9. Functions have static qualifier for its declaration by default.
a) true
b) false
c) Depends on the compiler
d) Depends on the standard
Discussion
10. Is initialisation mandatory for local static variables?
a) yes
b) no
c) Depends on the compiler
d) Depends on the standard
Discussion