Paper Tayyari

Lecture 23: Pre-processor Directives and Macros

MCQs, short and long questions from lecture 23.Lecture 23 ki MCQs, short aur long sawal.

9 MCQs · 9 MCQs from past papers9 MCQs · 9 MCQs past papers se

Start mock testMock test shuru karein
DoneHal kiye 0/9
– correctsahi
1.
★ Final term 2017 (paper 2)

A macro when takes arguments is called ______.

  1. Afunction
  2. Bprocedure
  3. Cparameterized macro
  4. Dsimple macro

A #define macro that takes arguments is a parameterized macro.

2.
★ Final term 2017 (paper 2)

Which of the following is NOT a preprocessor directive?

  1. A#error
  2. B#define
  3. C#line
  4. D#ndefine

#ndefine does not exist; #error, #define and #line are valid directives.

3.
★ Final term solved MCQs (Moaaz & Asad)

If we define an identifier with the statement #define PI 3.1415926 then during the execution of the program the value of PI __________.

  1. Acan not be replaced
  2. BNone of the given options
  3. CRemain constant.
  4. Dcan be changed by some operation

The preprocessor substitutes the constant text, so PI cannot change at run time.

4.
★ Final term solved MCQs (Moaaz & Asad)

All preprocessor directives are started with the symbol______.

  1. A*
  2. B+
  3. C@
  4. D#

Every preprocessor directive begins with #.

5.
★ Final term solved MCQs (Moaaz & Asad)

We can also do conditional compilation with preprocessor directives.

  1. ATrue
  2. BFalse

#if, #ifdef, #ifndef, #else and #endif provide conditional compilation.

6.
★ Final term solved MCQs (Moaaz & Asad)

Where we can include a header file in the program?

  1. Aany where
  2. Bin start
  3. Cat the end
  4. Dnone of the given options.

#include can appear anywhere, though it is normally placed at the top.

7.
★ Solved MCQs collection

Which one is the correct syntax for defining an identifier PI with preprocessor directive?

  1. A#define PI 3.1415926;
  2. B#define PI 3.1415926
  3. C#define PI = 3.1415926 ;
  4. D#define PI = 3.1415926

A #define uses name and replacement text with no = and no semicolon.

8.
★ Midterm Spring 2009

In C/C++ the #include is called,

  1. AHeader file
  2. BPreprocessor Directive
  3. CStatement
  4. DFunction

Lines starting with # are preprocessor directives.

9.
★ Past paper collection

Symbolic constant PI can be defined as:

  1. A#define PI 3.14 ;
  2. B#define PI 3.14
  3. C#define PI=3.14
  4. D# include pi= 3.14

#define takes the name and replacement text with no = and no semicolon.