C Programming Questions and Answers on C-Preprocessor Directives for Freshers

1. Property which allows to produce different executable for different platforms in C is called?

a) File inclusion
b) Selective inclusion
c) Conditional compilation
d) Recursive macros
Answer: c

Explanation: Conditional compilation is the preprocessor facility to produce different executable.
2. #include is called

a) Preprocessor directive
b) Inclusion directive
c) File inclusion directive
d) None of the mentioned
Answer: a
3. C preprocessors can have compiler specific features.

a) true
b) false
c) Depends on the standard
d) Depends on the platform
Answer: a

Explanation: #pragma is compiler specific feature.
4. What is the output of this C code?
  1. #include 
  2. #define foo(m, n) m * n = 10
  3. int main()
  4. {
  5.     printf("in main\n");
  6. }
a) In main
b) Compilation error as lvalue is required for the expression m*n=10
c) Preprocessor error as lvalue is required for the expression m*n=10
d) None of the mentioned
Answer: a

Explanation:Preprocessor just replaces whatever is given compiler then checks for error at the replaced part of the code. Here it is not replaced anywhere.
Output:
$ cc pgm1.c
$ a.out
in main
5. C preprocessor is conceptually the first step during compilation

a) true
b) false
c) Depends on the compiler
d) Depends on the standard
Answer: a
6. Preprocessor feature that supply line numbers and filenames to compiler is called?

a) Selective inclusion
b) macro substitution
c) Concatenation
d) Line control
Answer: d
7. #include are _______ files and #include “somefile.h” ________ files.

a) Library, Library
b) Library, user-created header
c) User-created header, library
d) They can include all types of file
Answer: d

Explanation: Both of these statement can be used to select any file.
8. A preprocessor is a program

a) That processes its input data to produce output that is used as input to another program
b) That is nothing but a loader
c) That links various source files
d) All of the mentioned
Answer: a

Explanation: A preprocessor is a preprocessor is a program that processes its input data to produce output that is used as input to another program.
9. Which of the following are C preprocessors?

a) #ifdef
b) #define
c) #endif
d) all of the mentioned
Answer: d
10. #include statement must be written

a) Before main()
b) Before any scanf/printf
c) After main()
d) It can be written anywhere
Answer: b

Explanation: Using these directives before main() improves readability.
11. #pragma exit is primarily used for?

a) Checking memory leaks after exitting the program
b) Informing Operating System that program has terminated
c) Running a function at exitting the program
d) No such preprocessor exist
Answer: c

Explanation: It is primarily used for running a function upon exitting the program.
12. What is the output of this C code?

  1.     #include 
  2.     int main()
  3.     {
  4.         int one = 1, two = 2;
  5.         #ifdef next
  6.         one = 2;
  7.         two = 1;
  8.         #endif
  9.         printf("%d, %d", one, two);
  10.     }
a) 1, 1
b) 1, 2
c) 2, 1
d) 2, 2
Answer: b
13. The C-preprocessors are specified with _________symbol.

a) #
b) $
c) ” ”
d) None of the mentioned
Answer: a

Explanation: The C-preprocessors are specified with # symbol.
14. The #include directive

a) Tells the preprocessor to grab the text of a file and place it directly into the current file
b) Statements are not typically placed at the top of a program
c) All of the mentioned
d) None of the mentioned
Answer: a

Explanation: The #include directive tells the preprocessor to grab the text of a file and place it directly into the current file and are statements are typically placed at the top of a program.
15. The preprocessor provides the ability for _______________

a) The inclusion of header files
b) The inclusion of macro expansions
c) Conditional compilation and line control.
d) All of the mentioned
Answer: d

Explanation: The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control.
16. If #include is used with file name in angular brackets

a) The file is searched for in the standard compiler include paths
b) The search path is expanded to include the current source directory
c) The search path will expand
d) None of the mentioned
Answer: a

Explanation: With the #include, if the filename is enclosed within angle brackets, the file is searched for in the standard compiler include paths.

Related

Multiple Choice Questions 1446619833080023578

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item