1) What are the types of C Preprocessor Directives.?
A) Macros
B) Conditional Compilation
2) Processor Directive in C language starts with.?
A) $ symbol (DOLLAR)
B) @ symbol (At The Rate)
Explanation:
eg. #include<stdio.h>
3) Preprocessor in C language works on.?
A) DOTC file (.c)
Explanation:
.C file is also called Source Code file.
4) What is the another name for .C file.?
A) Executable code
5) What is the keyword used to define a C macro.?
A) def
Explanation:
#define PI 3.1428
6) 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) 0
Explanation:
During expansion of source code, a=a*CVV is replaced with a=a*156. #define is used to declare global constants.
7) What is the C keyword used to create global Constants.?
A) constant
Explanation:
#define KM 1.6
8) 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 Expansion. 156 is also called Macro Expansion.
C) CVV is called Macro Template. 156 is called Macro Expansion.
9) What is the output file generated after processing a .C file.?
A) .h file
Explanation:
Yes. C program is converted to an executable file for distribution to outside world instead of sharing your original source code which may be copy righted logic.
10) How do you safeguard your .C file code from copying by outside developers or world.?
A) Encrypt a C file and share
B) Obfuscate a C file and share
C) Scramble a C file and share
D) Convert to Exe and share.
11) What is the output of C program with macros.?
#define ERRMSG printf("Some error.");
int main()
{
printf("JAR.");
ERRMSG;
return 0;
}
A) JAR.
Explanation:
In place of ERRMSG corresponding macro expansion is substituted blindly.
12) What is the output of C program with macros.?
#define ERRMSG(a) printf("Error=%d",a);
int main()
{
ERRMSG(10);
return 0;
}
A) ERRMSG(10)
Explanation:
Inside main the statment printf("Error=%d",10) is substituted.
printf("Error=%d",10);
13) What is the output of C program.?
#define LOGIC(a,b) (a==b)
int main()
{
if(LOGIC(5,5))
{
printf("SAME ");
}
return 0;
}
A) SAME
Explanation:
LOGIC(5,5) is replaced by (5==5) with outer paranthesis.
14) How do you separate a multiline macro in C language.?
A) Using * operator
Explanation:
#define LOOP(a) while(a>0) \
{printf("%d ",a);}
15) What is the output of C program.?
#define LOOP(a) for(int i=1;i<=a;i++) \
{printf("%d ",i);}
int main()
{
LOOP(5);
return 0;
}
A) 5
Explanation:
5 in LOOP(5) will be a condition for the FOR loop starting from i=1.
16) What is the output of C program.?
#define TANK(a) a*10+2
int main()
{
int a = TANK(2)*2;
printf("%d",a);
return 0;
}
A) 44
Explanation:
TANK(2)*2 is replaced by 2*20+2*2. It gives only 24. Remember, you should have put (a*10+2) paranthesis TANK definition to get expected results.
17) What is the file extension of expanded source code of .C file after preprocessing.?
A) .e file
Explanation:
def.c is converted into def.l file.
18) What is the command to preprocess a C file manually.?
A) pp abc.c
Explanation:
cpp refers to C Pre Processor.
cpp abc.c
19) 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.
20) What is the C Preprocessor directive to be used to add a header file or any file to existing C program.?
A) #add
Explanation:
#include<stdio.h>