wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Preprocessor Directives

Total questions: 25

Worksheet time: 23mins

Name
Class
Date
1.

What are the types of C Preprocessor Directives.?

a)

Macros

b)

Conditional Compilation

c)

File Inclusion

d)

All the above

2.

Processor Directive in C language starts with.?

a)

$ symbol (DOLLAR)

b)

@ symbol (At The Rate)

c)

& symbol (Ampersand)

d)

# symbol (HASH)

3.

Preprocessor in C language works on.?DOTC file (.c)

a)

DOTC file (.c)

b)

DOTEXE file (.exe)

c)

DOTH file (.h)

d)

DOTCP file (.cp)

4.

What is the another name for .C file.?

a)

Executable code

b)

Source Code

c)

Distributable Code

d)

Macro code

5.

What is the keyword used to define a C macro.?

a)

def

b)

definition

c)

define

d)

defy

6.

#include <stdio.h>

#define tokenpaster(n) printf ("token" #n " = %d", token##n)

int main(void) {

int token34 = 40;

tokenpaster(34);

return 0; }

a)

token34 = 40

b)

34

c)

token40

d)

token34

7.

How do you separate a multiline macro in C language.?

a)

Using * operator

b)

Using % operator

c)

Using \ operator

d)

Using + operator

8.

#include <stdio.h>

#define MAX(x,y) ((x) > (y) ? (x) : (y))

int main(void) {

printf("Max between 20 and 10 is %d\n", MAX(10, 20));

return 0; }

a)

10

b)

error

c)

20

d)

Max between 20 and 10 is 20

9.

#include <stdio.h>

#define message_for(a, b) \

printf(#a " and " #b ": are alphabets!\n")

int main(void) {

message_for(C,D);

return 0; }

a)

error

b)

C and D are alphabets

c)

C "and" D are alphabets

10.

#include <stdio.h>

#if !defined (MESSAGE)

#define MESSAGE "You wish!"

#endif

int main(void) {

printf("Here is the message: %s\n", MESSAGE);

return 0; }

a)

nothing is printed

b)

error

c)

Here is the message: You wish!

11.

What is the output of C program with #define.?

#define CVV 156

int main() {

int a=10;

a = a*CVV;

printf("CVV=%d",a);

return 0; }

a)

error

b)

1560

c)

0

12.

What is the C keyword used to create global Constants.?

a)

const

b)

define

c)

static

d)

def

13.

Choose a correct C statement about #define statement.?

#define CVV 156

a)

CVV is called Macro Expansion. 156 is called Macro Template.

b)

CVV is called Macro Template. 156 is called Macro Expansion.

c)

error

14.

What is the output file generated after processing a .C file.?

a)

object file

b)

executable file

c)

.bak file

15.

#include <stdio.h>

#define LOOP(a) for(int i=1;i<=a;i++) \

{printf("%d ",i);}

int main()

{

LOOP(5);

return 0;

}

a)

error

b)

1 2 3 4 5

c)

12345

16.

#include <stdio.h>

#define ERRMSG(a) printf("Error=%d",a);

int main()

{

ERRMSG(10);

return 0;

}

a)

Error=10

b)

error

c)

no output

17.

What is the file extension of expanded source code of .C file after preprocessing.?

a)

.exe

b)

.c

c)

.i

d)

.p

18.

Choose a correct statement about C Macro.?

a)

Macro template(eg. PI or function) will be replaced by Macro Expansion(3.1428) as many number of times as it appears in the C program increasing Source Code size in bytes.

b)

Macros increase program speed when compared to functions.

c)

Functions use less memory as the program code is written and placed only one place in source code. Macros put function code everywhere it is called again and again.

d)

All the above

19.

What does #include<stdio.h> does in c language.?

a)

It includes stdio.h into existing C program.

b)

#include increases the size of C program by including the specified file contents like functions, constants etc.

c)

#include includes specified file before compilation.

d)

All the above

20.

#define CVV 156

int main() {

#ifdef CVV

printf("CVV YES");

#else

printf("CVV NO");

#endif

return 0; }

a)

156

b)

CVV YES

c)

CVV NO

d)

printf("CVV YES");

21.

int main() {

#ifdef CVV

printf("CVV YES");

#else

#define CVV 199

#endif

printf("NEW CVV=%d",CVV);

return 0; }

a)

CVV 199

b)

printf("CVV YES");

c)

CVV YES

d)

NEW CVV=199

22.

void show();

int main() {

#ifndef CVV

#define CVV 199

#endif

show();

return 0; }

void show() {

printf("CVV=%d",CVV); }

a)

No output

b)

CVV=0

c)

Compiler error

d)

CVV=199

23.

int main() {

#ifdef CVV

#define CVV 199

#elif PVV

printf("Inside ELIF");

#else

printf("Inside ELSE");

#endif

return 0; }

a)

Inside ELSE

b)

Inside ELIF

c)

error

d)

no output

24.

What is a Pragma in C language.?

a)

A Pragma may be an instruction to build tool to process or generate comments

b)

A Pragma may be an instruction to compiler to execute specific functions at specific times say startup or exit of program.

c)

A pragma may be an instruction to tell compiler to ignore certain warnings.

d)

All the above

25.

void show1();

void show2();

#pragma startup show1

#pragma exit show2

int main() {

printf("MAIN."); }

void show1() {

printf("START."); }

void show2() {

printf("END."); }

a)

MAIN.START.END.

b)

START.MAIN.END

c)

START.END.MAIN

d)

END.START.MAIN