NEW
Font size
WorksheetsPreprocessor Directives
Total questions: 25
Worksheet time: 23mins
What are the types of C Preprocessor Directives.?
Macros
Conditional Compilation
File Inclusion
All the above
Processor Directive in C language starts with.?
$ symbol (DOLLAR)
@ symbol (At The Rate)
& symbol (Ampersand)
# symbol (HASH)
Preprocessor in C language works on.?DOTC file (.c)
DOTC file (.c)
DOTEXE file (.exe)
DOTH file (.h)
DOTCP file (.cp)
What is the another name for .C file.?
Executable code
Source Code
Distributable Code
Macro code
What is the keyword used to define a C macro.?
def
definition
define
defy
#include <stdio.h>
#define tokenpaster(n) printf ("token" #n " = %d", token##n)
int main(void) {
int token34 = 40;
tokenpaster(34);
return 0; }
token34 = 40
34
token40
token34
How do you separate a multiline macro in C language.?
Using * operator
Using % operator
Using \ operator
Using + operator
#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; }
10
error
20
Max between 20 and 10 is 20
#include <stdio.h>
#define message_for(a, b) \
printf(#a " and " #b ": are alphabets!\n")
int main(void) {
message_for(C,D);
return 0; }
error
C and D are alphabets
C "and" D are alphabets
#include <stdio.h>
#if !defined (MESSAGE)
#define MESSAGE "You wish!"
#endif
int main(void) {
printf("Here is the message: %s\n", MESSAGE);
return 0; }
nothing is printed
error
Here is the message: You wish!
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; }
error
1560
0
What is the C keyword used to create global Constants.?
const
define
static
def
Choose a correct C statement about #define statement.?
#define CVV 156
CVV is called Macro Expansion. 156 is called Macro Template.
CVV is called Macro Template. 156 is called Macro Expansion.
error
What is the output file generated after processing a .C file.?
object file
executable file
.bak file
#include <stdio.h>
#define LOOP(a) for(int i=1;i<=a;i++) \
{printf("%d ",i);}
int main()
{
LOOP(5);
return 0;
}
error
1 2 3 4 5
12345
#include <stdio.h>
#define ERRMSG(a) printf("Error=%d",a);
int main()
{
ERRMSG(10);
return 0;
}
Error=10
error
no output
What is the file extension of expanded source code of .C file after preprocessing.?
.exe
.c
.i
.p
Choose a correct statement about C Macro.?
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.
Macros increase program speed when compared to functions.
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.
All the above
What does #include<stdio.h> does in c language.?
It includes stdio.h into existing C program.
#include increases the size of C program by including the specified file contents like functions, constants etc.
#include includes specified file before compilation.
All the above
#define CVV 156
int main() {
#ifdef CVV
printf("CVV YES");
#else
printf("CVV NO");
#endif
return 0; }
156
CVV YES
CVV NO
printf("CVV YES");
int main() {
#ifdef CVV
printf("CVV YES");
#else
#define CVV 199
#endif
printf("NEW CVV=%d",CVV);
return 0; }
CVV 199
printf("CVV YES");
CVV YES
NEW CVV=199
void show();
int main() {
#ifndef CVV
#define CVV 199
#endif
show();
return 0; }
void show() {
printf("CVV=%d",CVV); }
No output
CVV=0
Compiler error
CVV=199
int main() {
#ifdef CVV
#define CVV 199
#elif PVV
printf("Inside ELIF");
#else
printf("Inside ELSE");
#endif
return 0; }
Inside ELSE
Inside ELIF
error
no output
What is a Pragma in C language.?
A Pragma may be an instruction to build tool to process or generate comments
A Pragma may be an instruction to compiler to execute specific functions at specific times say startup or exit of program.
A pragma may be an instruction to tell compiler to ignore certain warnings.
All the above
void show1();
void show2();
#pragma startup show1
#pragma exit show2
int main() {
printf("MAIN."); }
void show1() {
printf("START."); }
void show2() {
printf("END."); }
MAIN.START.END.
START.MAIN.END
START.END.MAIN
END.START.MAIN
