Home
MCQS
C/C MCQ Quiz Hub
C Multiple Choice Questions C Functions Set 2
Choose a topic to test your knowledge and improve your C/C skills
1. What linkage does automatic variables have?
Internal linkage
External linkage
No linkage
None of the mentioned
2. Automatic variables are variables that are?
Declared within the scope of a block, usually a function
Declared outside all functions
Declared with auto keyword
Declared within the keyword extern
3. Automatic variables:
Exist only within that scope in which it is declared
Cease to exist after the block is exited
Both (a) & (b)
Only 1
4. Automatic variables are allocated memory in?
heap
Data segment
Code segment
stack
5. What is the output of this C code? void main() { int x; } here x is?
automatic variable
static variable
global variable
register variable
6. Automatic variables are initialized to?
0
Junk value
Nothing
Both (a) & (b)
7. The variable declaration with no storage class specified is by default:
auto
extern
static
register
8. What is the output of this C code? int x = 5; void main() { int x = 3; printf("%d", x); { x = 4; } printf("%d", x); }
Run time error
3 3
3 5
3 4
9. What is the scope of an external variable?
Whole source file in which it is definedB.
From the point of declaration to the end of the file in which it is defined
Any source file in a program
From the point of declaration to the end of the file being compiled
10. What is the scope of a function?
Whole source file in which it is defined
From the point of declaration to the end of the file in which it is defined
Any source file in a program
From the point of declaration to the end of the file being compiled
11. Which variable has the longest scope? int b; int main() { int c; return 0; } int a;
a
b
c
Both (a) and (b)
12. Array sizes are optional during array declaration by using ______ keyword.
auto
static
extern
register
13. What is the output of this C code? void main() { int x = 3; { x = 4; printf("%d", x); } }
4
3
0
Undefined
14. What is the output of this C code? int x = 5; void main() { int x = 3; m(); printf("%d", x); } void m() { x = 8; n(); } void n() { printf("%d", x); }
8 3
8 5
3 8
5 3
15. What is the output of this C code? static int x; void main() { int x; printf("x is %d", x); }
0
Junk value
Run time error
Nothing
16. What is the output of this C code? void main() { static int x; if (x++ < 2) main(); }
Infinite calls to main
Run time error
Varies
main is called twice
17. Which of the following is true for static variable?
It can be called from another function
It exists even after the function ends.
It can be modified in another function by sending it as a parameter.
All of the mentioned
18. Assignment statements assigning value to local static variables are executed only once?
true
False
Depends on the code
None of the mentioned
19. What is the format identifier for "static a = 20.5;?
%s
%d
%f
Illegal declaration due to absence of data type
20. Functions have static qualifier for its declaration by default.
True
False
Depends on the compiler
Depends on the standard
21. Is initialization mandatory for local static variables?
Yes
No
Depends on the compiler
Depends on the standard
Submit