

MCQOPTIONS
Saved Bookmarks
This section includes 65 Mcqs, each offering curated multiple-choice questions to sharpen your C Programming knowledge and support exam preparation. Choose a topic below to get started.
1. |
Would the following work? |
A. | Yes |
B. | No |
Answer» C. | |
2. |
Preprocessor directive can be used only on a macro that has been earlier |
A. | True |
B. | False |
Answer» B. False | |
3. |
There exists a way to prevent the same file from getting twice in the same program. |
A. | True |
B. | False |
Answer» B. False | |
4. |
Will the following program print the message infinite number of times? |
A. | Yes |
B. | No |
Answer» B. No | |
5. |
Preprocessor directive .. ... is used for conditional compilation. |
A. | True |
B. | False |
Answer» B. False | |
6. |
Will the program compile successfully? |
A. | Yes |
B. | No |
Answer» B. No | |
7. |
Which of the following are correct preprocessor directives in C? |
A. | 1, 2 |
B. | 4 |
C. | 1, 2, 4 |
D. | 1, 2, 3, 4 |
Answer» E. | |
8. |
Which of the following are correctly formed statements in C? |
A. | #define CUBE (X) (X*X*X); |
B. | #define CUBE(x) (X*X*X) |
C. | #define CUBE(X)(X*X*X) |
D. | #define CUBE(X) {X*X*X} |
Answer» D. #define CUBE(X) {X*X*X} | |
9. |
What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile? |
A. | It compiles |
B. | Compiles with an warning |
C. | Not compile |
D. | Compiles and print nothing |
Answer» D. Compiles and print nothing | |
10. |
In which stage the following code gets replaced by the contents of the file |
A. | During editing |
B. | During linking |
C. | During execution |
D. | During preprocessing |
Answer» E. | |
11. |
Will the following program print the message infinite number of times?_x000D_
#include
|
A. | Yes |
B. | No |
Answer» B. No | |
12. |
What will be the output of the program?
#include
|
A. | IndiaBIX... IndiaBIX... IndiaBIX |
B. | IndiaBIX... IndiaBIX... |
C. | Error: cannot use control instructions in macro |
D. | No output |
Answer» C. Error: cannot use control instructions in macro | |
13. |
What will be the output of the program?_x000D_
#include
|
A. | 12, 6, 12 |
B. | 11, 5, 11 |
C. | 11, 5, Garbage |
D. | 12, 6, Garbage |
Answer» B. 11, 5, 11 | |
14. |
Point out the error in the program
#include
|
A. | Error: unexpected end of file because there is no matching #endif |
B. | The number is odd |
C. | Garbage values |
D. | None of above |
Answer» B. The number is odd | |
15. |
What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile?_x000D_
#include
|
A. | It compiles |
B. | Compiles with an warning |
C. | Not compile |
D. | Compiles and print nothing |
Answer» D. Compiles and print nothing | |
16. |
What will be the output of the program?_x000D_
#include
|
A. | a = 10, b = 12 |
B. | a = 12, b = 10 |
C. | Error: Declaration not allowed in macro |
D. | Error: Undefined symbol 't' |
Answer» C. Error: Declaration not allowed in macro | |
17. |
The output of the following program is:#define f(g,g2) g##g2void main(){int var12=100;printf("%d", f(var,12));} |
A. | yntax error |
B. | untime error |
C. | ##g2 |
D. | 00 |
E. | 0012 |
Answer» E. 0012 | |
18. |
What will be output after executing following code?#include# define a 10void main(){printf("%d..", a);foo();printf("%d", a);}void foo(){#undef a#define a 50} |
A. | 0..50 |
B. | 0..10 |
C. | |
Answer» C. | |
19. |
What will be the output of the following program?#include
|
A. | 5 |
B. | 2 |
C. | 0 |
D. | 1 |
E. | one of these |
Answer» D. 1 | |
20. |
Choose the correct statement.I.The scope of a macro definition need not be the entire program.II.The scope of a macro definition extends from the point of definition to the end of the file.III. New line is a macro definition delimiter.IV.A macro definition may go beyond a line. |
A. | and II |
B. | I and III |
C. | , II and III |
D. | I, III and IV |
E. | , II, III and IV |
Answer» F. | |
21. |
What will be the output of the program code?#include
|
A. | 0 |
B. | 0 |
C. | ompiler Error |
D. | one of These |
Answer» B. 0 | |
22. |
What will be the output of the program?#include
|
A. | izeof(i)=2 |
B. | izeof(i)=1 |
C. | ompiler Error |
D. | one of These |
Answer» C. ompiler Error | |
23. |
Once preprocessing is over and the program is sent for the compilation the macros are removed from the expanded source code. |
A. | 1 |
B. | |
Answer» B. | |
24. |
A header file contains macros, structure declaration and function prototypes. |
A. | 1 |
B. | |
Answer» B. | |
25. |
What will be the output of the program?
#include
|
A. | junk |
B. | MESS |
C. | Error |
D. | Nothing will print |
Answer» C. Error | |
26. |
What will be the output of the program?
#include
|
A. | 10 |
B. | 20 |
C. | 1020 |
D. | 12 |
Answer» C. 1020 | |
27. |
Preprocessor directive #ifdef .. #else ... #endif is used for conditional compilation. |
A. | 1 |
B. | |
Answer» B. | |
28. |
What will be the output of the program?
#include
|
A. | Error: in macro substitution |
B. | Error: invalid reference 'x' in macro |
C. | print 'multiply' |
D. | No output |
Answer» D. No output | |
29. |
A preprocessor directive is a message from compiler to a linker. |
A. | 1 |
B. | |
Answer» C. | |
30. |
Every C program will contain at least one preprocessor directive. |
A. | 1 |
B. | |
Answer» C. | |
31. |
Macros have a local scope. |
A. | 1 |
B. | |
Answer» C. | |
32. |
What will be the output of the program?
#include
|
A. | 2, 3, 4, |
B. | 2, 2, 2, |
C. | 3, 3, 3, |
D. | 4, 4, 4, |
Answer» B. 2, 2, 2, | |
33. |
What will be the output of the program?
#include
|
A. | IndiaBIX... IndiaBIX... IndiaBIX |
B. | IndiaBIX... IndiaBIX... |
C. | Error: cannot use control instructions in macro |
D. | No output |
Answer» C. Error: cannot use control instructions in macro | |
34. |
The preprocessor can trap simple errors like missing declarations, nested comments or mismatch of braces. |
A. | 1 |
B. | |
Answer» C. | |
35. |
Macros with arguments are allowed |
A. | 1 |
B. | |
Answer» B. | |
36. |
What will be the output of the program?
#include
|
A. | 8 |
B. | 9 |
C. | 6 |
D. | 5 |
Answer» C. 6 | |
37. |
What will be the output of the program?
#include
|
A. | 5 |
B. | 9 |
C. | 10 |
D. | 3+7 |
Answer» D. 3+7 | |
38. |
Will it result in to an error if a header file is included twice? |
A. | Yes |
B. | No |
C. | It is compiler dependent. |
Answer» D. | |
39. |
What will be the output of the program?
#include
|
A. | a = 10, b = 12 |
B. | a = 12, b = 10 |
C. | Error: Declaration not allowed in macro |
D. | Error: Undefined symbol 't' |
Answer» C. Error: Declaration not allowed in macro | |
40. |
It is necessary that a header files should have a .h extension? |
A. | Yes |
B. | No |
Answer» C. | |
41. |
A macro must always be defined in capital letters. |
A. | 1 |
B. | |
C. | 1 |
D. | |
Answer» C. 1 | |
42. |
What will be the output of the program?
#include
|
A. | str1=IndiaBIX str2=BIX |
B. | str1=India str2=BIX |
C. | str1=India str2=IndiaBIX |
D. | Error: in macro substitution |
Answer» C. str1=India str2=IndiaBIX | |
43. |
What will be the output of the program?
#include
|
A. | 25 |
B. | 11 |
C. | Error |
D. | Garbage value |
Answer» C. Error | |
44. |
What will be the output of the program?
#include
|
A. | 3 |
B. | 4 |
C. | 0 |
D. | No output |
Answer» B. 4 | |
45. |
What will be the output of the program?
#include
|
A. | 9, 4 |
B. | 27, 4 |
C. | 27, 6 |
D. | Error |
Answer» D. Error | |
46. |
Will the program compile successfully?
#include
|
A. | Yes |
B. | No |
Answer» B. No | |
47. |
What will be the output of the program?
#include
|
A. | int=2, int=3, int=4 |
B. | int=2, int=2, int=2 |
C. | int=3, int=3, int=3 |
D. | int=4, int=4, int=4 |
Answer» B. int=2, int=2, int=2 | |
48. |
Will the program compile successfully?
#include
|
A. | Yes |
B. | No |
Answer» B. No | |
49. |
Which of the following are correctly formed #define statements in C? |
A. | #define CUBE (X) (X*X*X); |
B. | #define CUBE(x) (X*X*X) |
C. | #define CUBE(X)(X*X*X) |
D. | #define CUBE(X) {X*X*X} |
Answer» D. #define CUBE(X) {X*X*X} | |
50. |
Would the following typedef work? typedef #include l; |
A. | Yes |
B. | No |
Answer» C. | |