C Programming C Preprocessor Online Test
Finish Quiz
0 of 30 questions completed
Questions:
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
Information
C Programming C Preprocessor Online Test. C Programming Question and Answers in English. C Programming C Preprocessor Online mock test paper is free for all students and Very Helpful for Exam Preparation. C Programming C Preprocessor Online Quiz. C Programming Online Mock test for C Preprocessor Topic. Here we are providing C Programming C Preprocessor Online Test Series in English. Check C Programming Mock Test Series 2024-2024.
This paper has 30 questions.
Time allowed is 30 minutes.
The C Programming online Mock Test Exam is Very helpful for all students. Now Scroll down below n click on “Start Quiz” or “Start Test” and Test yourself.
You have already completed the quiz before. Hence you can not start it again.
Quiz is loading...
You must sign in or sign up to start the quiz.
You have to finish following quiz, to start this quiz:
Results
0 of 30 questions answered correctly
Your time:
Time has elapsed
You have reached 0 of 0 points, (0)
Average score |
|
Your score |
|
Categories
- Not categorized 0%
Pos. | Name | Entered on | Points | Result |
---|---|---|---|---|
Table is loading | ||||
No data available | ||||
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- Answered
- Review
-
Question 1 of 30
1. Question
What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile?
#include<stdio.h> #define SWAP(a, b, c)(c t; t=a, a=b, b=t) int main() { int x=10, y=20; SWAP(x, y, int); printf("%d %d\n", x, y); return 0; }
Correct
The code won’t compile since declaration of t cannot occur within parenthesis.Incorrect
The code won’t compile since declaration of t cannot occur within parenthesis. -
Question 2 of 30
2. Question
In which stage the following code
#include<stdio.h>
gets replaced by the contents of the file stdio.hCorrect
The preprocessor replaces the line #include <stdio.h> with the system header file of that name. More precisely, the entire text of the file ‘stdio.h’ replaces the #include directive.
Incorrect
The preprocessor replaces the line #include <stdio.h> with the system header file of that name. More precisely, the entire text of the file ‘stdio.h’ replaces the #include directive.
-
Question 3 of 30
3. Question
What will be the output of the program?
#include<stdio.h> #define MAN(x, y) ((x)>(y)) ? (x):(y); int main() { int i=10, j=5, k=0; k = MAN(++i, j++); printf("%d, %d, %d\n", i, j, k); return 0; }
Correct
The macro MAN(x, y) ((x)>(y)) ? (x):(y); returns the biggest number of given two numbers.
Step 1: int i=10, j=5, k=0; The variable i, j, k are declared as an integer type and initialized to value 10, 5, 0 respectively.
Step 2: k = MAN(++i, j++); becomes,
=> k = ((++i)>(j++)) ? (++i):(j++);
=> k = ((11)>(5)) ? (12):(6);
=> k = 12
Step 3: printf(“%d, %d, %d\n”, i, j, k); It prints the variable i, j, k.
In the above macro step 2 the variable i value is increemented by 2 and variable j value is increemented by 1.
Hence the output of the program is 12, 6, 12
Incorrect
The macro MAN(x, y) ((x)>(y)) ? (x):(y); returns the biggest number of given two numbers.
Step 1: int i=10, j=5, k=0; The variable i, j, k are declared as an integer type and initialized to value 10, 5, 0 respectively.
Step 2: k = MAN(++i, j++); becomes,
=> k = ((++i)>(j++)) ? (++i):(j++);
=> k = ((11)>(5)) ? (12):(6);
=> k = 12
Step 3: printf(“%d, %d, %d\n”, i, j, k); It prints the variable i, j, k.
In the above macro step 2 the variable i value is increemented by 2 and variable j value is increemented by 1.
Hence the output of the program is 12, 6, 12
-
Question 4 of 30
4. Question
What will be the output of the program?
#include<stdio.h> #define SQUARE(x) x*x int main() { float s=10, u=30, t=2, a; a = 2*(s-u*t)/SQUARE(t); printf("Result = %f", a); return 0; }
Correct
The macro function SQUARE(x) x*x calculate the square of the given number ‘x’. (Eg: 102)
Step 1: float s=10, u=30, t=2, a; Here the variable s, u, t, a are declared as an floating point type and the variable s, u, t are initialized to 10, 30, 2.
Step 2: a = 2*(s-u*t)/SQUARE(t); becomes,
=> a = 2 * (10 – 30 * 2) / t * t; Here SQUARE(t) is replaced by macro to t*t .
=> a = 2 * (10 – 30 * 2) / 2 * 2;
=> a = 2 * (10 – 60) / 2 * 2;
=> a = 2 * (-50) / 2 * 2 ;
=> a = 2 * (-25) * 2 ;
=> a = (-50) * 2 ;
=> a = -100;
Step 3: printf(“Result=%f”, a); It prints the value of variable ‘a’.
Hence the output of the program is -100
Incorrect
The macro function SQUARE(x) x*x calculate the square of the given number ‘x’. (Eg: 102)
Step 1: float s=10, u=30, t=2, a; Here the variable s, u, t, a are declared as an floating point type and the variable s, u, t are initialized to 10, 30, 2.
Step 2: a = 2*(s-u*t)/SQUARE(t); becomes,
=> a = 2 * (10 – 30 * 2) / t * t; Here SQUARE(t) is replaced by macro to t*t .
=> a = 2 * (10 – 30 * 2) / 2 * 2;
=> a = 2 * (10 – 60) / 2 * 2;
=> a = 2 * (-50) / 2 * 2 ;
=> a = 2 * (-25) * 2 ;
=> a = (-50) * 2 ;
=> a = -100;
Step 3: printf(“Result=%f”, a); It prints the value of variable ‘a’.
Hence the output of the program is -100
-
Question 5 of 30
5. Question
What will be the output of the program?
#include<stdio.h> #define SQR(x)(x*x) int main() { int a, b=3; a = SQR(b+2); printf("%d\n", a); return 0; }
Correct
The macro function SQR(x)(x*x) calculate the square of the given number ‘x’. (Eg: 102)
Step 1: int a, b=3; Here the variable a, b are declared as an integer type and the variable b is initialized to 3.
Step 2: a = SQR(b+2); becomes,
=> a = b+2 * b+2; Here SQR(x) is replaced by macro to x*x .
=> a = 3+2 * 3+2;
=> a = 3 + 6 + 2;
=> a = 11;
Step 3: printf(“%d\n”, a); It prints the value of variable ‘a’.
Hence the output of the program is 11
Incorrect
The macro function SQR(x)(x*x) calculate the square of the given number ‘x’. (Eg: 102)
Step 1: int a, b=3; Here the variable a, b are declared as an integer type and the variable b is initialized to 3.
Step 2: a = SQR(b+2); becomes,
=> a = b+2 * b+2; Here SQR(x) is replaced by macro to x*x .
=> a = 3+2 * 3+2;
=> a = 3 + 6 + 2;
=> a = 11;
Step 3: printf(“%d\n”, a); It prints the value of variable ‘a’.
Hence the output of the program is 11
-
Question 6 of 30
6. Question
What will be the output of the program?
#include<stdio.h> #define JOIN(s1, s2) printf("%s=%s %s=%s \n", #s1, s1, #s2, s2); int main() { char *str1="India"; char *str2="BIX"; JOIN(str1, str2); return 0; }
Correct
Incorrect
-
Question 7 of 30
7. Question
What will be the output of the program?
#include<stdio.h> #define CUBE(x) (x*x*x) int main() { int a, b=3; a = CUBE(b++); printf("%d, %d\n", a, b); return 0; }
Correct
The macro function CUBE(x) (x*x*x) calculates the cubic value of given number(Eg: 103.)
Step 1: int a, b=3; The variable a and b are declared as an integer type and varaible b id initialized to 3.
Step 2: a = CUBE(b++); becomes
=> a = b++ * b++ * b++;
=> a = 3 * 3 * 3; Here we are using post-increement operator, so the 3 is not incremented in this statement.
=> a = 27; Here, 27 is store in the variable a. By the way, the value of variable b is incremented by 3. (ie: b=6)
Step 3: printf(“%d, %d\n”, a, b); It prints the value of variable a and b.
Hence the output of the program is 27, 6.
Incorrect
The macro function CUBE(x) (x*x*x) calculates the cubic value of given number(Eg: 103.)
Step 1: int a, b=3; The variable a and b are declared as an integer type and varaible b id initialized to 3.
Step 2: a = CUBE(b++); becomes
=> a = b++ * b++ * b++;
=> a = 3 * 3 * 3; Here we are using post-increement operator, so the 3 is not incremented in this statement.
=> a = 27; Here, 27 is store in the variable a. By the way, the value of variable b is incremented by 3. (ie: b=6)
Step 3: printf(“%d, %d\n”, a, b); It prints the value of variable a and b.
Hence the output of the program is 27, 6.
-
Question 8 of 30
8. Question
What will be the output of the program?
#include<stdio.h> #define PRINT(int) printf("int=%d, ", int); int main() { int x=2, y=3, z=4; PRINT(x); PRINT(y); PRINT(z); return 0; }
Correct
The macro PRINT(int) print(“%d,”, int); prints the given variable value in an integer format.
Step 1: int x=2, y=3, z=4; The variable x, y, z are declared as an integer type and initialized to 2, 3, 4 respectively.
Step 2: PRINT(x); becomes printf(“int=%d,”,x). Hence it prints ‘int=2’.
Step 3: PRINT(y); becomes printf(“int=%d,”,y). Hence it prints ‘int=3’.
Step 4: PRINT(z); becomes printf(“int=%d,”,z). Hence it prints ‘int=4’.
Hence the output of the program is int=2, int=3, int=4.
Incorrect
The macro PRINT(int) print(“%d,”, int); prints the given variable value in an integer format.
Step 1: int x=2, y=3, z=4; The variable x, y, z are declared as an integer type and initialized to 2, 3, 4 respectively.
Step 2: PRINT(x); becomes printf(“int=%d,”,x). Hence it prints ‘int=2’.
Step 3: PRINT(y); becomes printf(“int=%d,”,y). Hence it prints ‘int=3’.
Step 4: PRINT(z); becomes printf(“int=%d,”,z). Hence it prints ‘int=4’.
Hence the output of the program is int=2, int=3, int=4.
-
Question 9 of 30
9. Question
What will be the output of the program?
#include<stdio.h> #define SWAP(a, b) int t; t=a, a=b, b=t; int main() { int a=10, b=12; SWAP(a, b); printf("a = %d, b = %d\n", a, b); return 0; }
Correct
The macro SWAP(a, b) int t; t=a, a=b, b=t; swaps the value of the given two variable.
Step 1: int a=10, b=12; The variable a and b are declared as an integer type and initialized to 10, 12 respectively.
Step 2: SWAP(a, b);. Here the macro is substituted and it swaps the value to variable a and b.
Hence the output of the program is 12, 10.
Incorrect
The macro SWAP(a, b) int t; t=a, a=b, b=t; swaps the value of the given two variable.
Step 1: int a=10, b=12; The variable a and b are declared as an integer type and initialized to 10, 12 respectively.
Step 2: SWAP(a, b);. Here the macro is substituted and it swaps the value to variable a and b.
Hence the output of the program is 12, 10.
-
Question 10 of 30
10. Question
What will be the output of the program?
#include<stdio.h> #define FUN(i, j) i##j int main() { int va1=10; int va12=20; printf("%d\n", FUN(va1, 2)); return 0; }
Correct
The following program will make you understand about ## (macro concatenation) operator clearly.
#include<stdio.h> #define FUN(i, j) i##j int main() { int First = 10; int Second = 20; char FirstSecond[] = "IndiaBIX"; printf("%s\n", FUN(First, Second) ); return 0; } Output: ------- IndiaBIX
The preprocessor will replace FUN(First, Second) as FirstSecond.
Therefore, the printf(“%s\n”, FUN(First, Second) ); statement will become as printf(“%s\n”, FirstSecond );
Hence it prints IndiaBIX as output.
Like the same, the line printf(“%d\n”, FUN(va1, 2)); given in the above question will become as printf(“%d\n”, va12 );.
Therefore, it prints 20 as output.
Incorrect
The following program will make you understand about ## (macro concatenation) operator clearly.
#include<stdio.h> #define FUN(i, j) i##j int main() { int First = 10; int Second = 20; char FirstSecond[] = "IndiaBIX"; printf("%s\n", FUN(First, Second) ); return 0; } Output: ------- IndiaBIX
The preprocessor will replace FUN(First, Second) as FirstSecond.
Therefore, the printf(“%s\n”, FUN(First, Second) ); statement will become as printf(“%s\n”, FirstSecond );
Hence it prints IndiaBIX as output.
Like the same, the line printf(“%d\n”, FUN(va1, 2)); given in the above question will become as printf(“%d\n”, va12 );.
Therefore, it prints 20 as output.
-
Question 11 of 30
11. Question
What will be the output of the program?
#include<stdio.h> #define FUN(arg) do\ {\ if(arg)\ printf("IndiaBIX...", "\n");\ }while(--i) int main() { int i=2; FUN(i<3); return 0; }
Correct
The macro FUN(arg) prints the statement “IndiaBIX…” untill the while condition is satisfied.
Step 1: int i=2; The variable i is declared as an integer type and initialized to 2.
Step 2: FUN(i<3); becomes,
do { if(2 < 3) printf("IndiaBIX...", "\n"); }while(--2)
After the 2 while loops the value of i becomes ‘0’(zero). Hence the while loop breaks.
Hence the output of the program is “IndiaBIX… IndiaBIX…”
Incorrect
The macro FUN(arg) prints the statement “IndiaBIX…” untill the while condition is satisfied.
Step 1: int i=2; The variable i is declared as an integer type and initialized to 2.
Step 2: FUN(i<3); becomes,
do { if(2 < 3) printf("IndiaBIX...", "\n"); }while(--2)
After the 2 while loops the value of i becomes ‘0’(zero). Hence the while loop breaks.
Hence the output of the program is “IndiaBIX… IndiaBIX…”
-
Question 12 of 30
12. Question
What will be the output of the program?
#include<stdio.h> #define MAX(a, b) (a > b ? a : b) int main() { int x; x = MAX(3+2, 2+7); printf("%d\n", x); return 0; }
Correct
The macro MAX(a, b) (a > b ? a : b) returns the biggest value of the given two numbers.
Step 1 : int x; The variable x is declared as an integer type.
Step 2 : x = MAX(3+2, 2+7); becomes,
=> x = (3+2 > 2+7 ? 3+2 : 2+7)
=> x = (5 > 9 ? 5 : 9)
=> x = 9
Step 3 : printf(“%d\n”, x); It prints the value of variable x.
Hence the output of the program is 9.
Incorrect
The macro MAX(a, b) (a > b ? a : b) returns the biggest value of the given two numbers.
Step 1 : int x; The variable x is declared as an integer type.
Step 2 : x = MAX(3+2, 2+7); becomes,
=> x = (3+2 > 2+7 ? 3+2 : 2+7)
=> x = (5 > 9 ? 5 : 9)
=> x = 9
Step 3 : printf(“%d\n”, x); It prints the value of variable x.
Hence the output of the program is 9.
-
Question 13 of 30
13. Question
What will be the output of the program?
#include<stdio.h> #define MIN(x, y) (x<y)? x : y; int main() { int x=3, y=4, z; z = MIN(x+y/2, y-1); if(z > 0) printf("%d\n", z); return 0; }
Correct
The macro MIN(x, y) (x<y)? x : y; returns the smallest value from the given two numbers.
Step 1: int x=3, y=4, z; The variable x, y, z are declared as an integer type and the variable x, y are initialized to value 3, 4 respectively.
Step 2: z = MIN(x+y/2, y-1); becomes,
=> z = (x+y/2 < y-1)? x+y/2 : y – 1;
=> z = (3+4/2 < 4-1)? 3+4/2 : 4 – 1;
=> z = (3+2 < 4-1)? 3+2 : 4 – 1;
=> z = (5 < 3)? 5 : 3;
The macro return the number 3 and it is stored in the variable z.
Step 3: if(z > 0) becomes if(3 > 0) here the if condition is satisfied. It executes the if block statements.
Step 4: printf(“%d\n”, z);. It prints the value of variable z.
Hence the output of the program is 3
Incorrect
The macro MIN(x, y) (x<y)? x : y; returns the smallest value from the given two numbers.
Step 1: int x=3, y=4, z; The variable x, y, z are declared as an integer type and the variable x, y are initialized to value 3, 4 respectively.
Step 2: z = MIN(x+y/2, y-1); becomes,
=> z = (x+y/2 < y-1)? x+y/2 : y – 1;
=> z = (3+4/2 < 4-1)? 3+4/2 : 4 – 1;
=> z = (3+2 < 4-1)? 3+2 : 4 – 1;
=> z = (5 < 3)? 5 : 3;
The macro return the number 3 and it is stored in the variable z.
Step 3: if(z > 0) becomes if(3 > 0) here the if condition is satisfied. It executes the if block statements.
Step 4: printf(“%d\n”, z);. It prints the value of variable z.
Hence the output of the program is 3
-
Question 14 of 30
14. Question
What will be the output of the program?
#include<stdio.h> #define str(x) #x #define Xstr(x) str(x) #define oper multiply int main() { char *opername = Xstr(oper); printf("%s\n", opername); return 0; }
Correct
The macro #define str(x) #x replaces the symbol ‘str(x)’ with ‘x’.
The macro #define Xstr(x) str(x) replaces the symbol ‘Xstr(x)’ with ‘str(x)’.
The macro #define oper multiply replaces the symbol ‘oper’ with ‘multiply’.
Step 1: char *opername = Xstr(oper); The varible *opername is declared as an pointer to a character type.
=> Xstr(oper); becomes,
=> Xstr(multiply);
=> str(multiply)
=> char *opername = multiply
Step 2: printf(“%s\n”, opername); It prints the value of variable opername.
Hence the output of the program is “multiply”
Incorrect
The macro #define str(x) #x replaces the symbol ‘str(x)’ with ‘x’.
The macro #define Xstr(x) str(x) replaces the symbol ‘Xstr(x)’ with ‘str(x)’.
The macro #define oper multiply replaces the symbol ‘oper’ with ‘multiply’.
Step 1: char *opername = Xstr(oper); The varible *opername is declared as an pointer to a character type.
=> Xstr(oper); becomes,
=> Xstr(multiply);
=> str(multiply)
=> char *opername = multiply
Step 2: printf(“%s\n”, opername); It prints the value of variable opername.
Hence the output of the program is “multiply”
-
Question 15 of 30
15. Question
What will be the output of the program?
#include<stdio.h> #define MESS junk int main() { printf("MESS\n"); return 0; }
Correct
printf(“MESS\n”); It prints the text “MESS”. There is no macro calling inside the printf statement occured.
Incorrect
printf(“MESS\n”); It prints the text “MESS”. There is no macro calling inside the printf statement occured.
-
Question 16 of 30
16. Question
What will be the output of the program?
#include<stdio.h> #define PRINT(i) printf("%d,",i) int main() { int x=2, y=3, z=4; PRINT(x); PRINT(y); PRINT(z); return 0; }
Correct
The macro PRINT(i) print(“%d,”, i); prints the given variable value in an integer format.
Step 1: int x=2, y=3, z=4; The variable x, y, z are declared as an integer type and initialized to 2, 3, 4 respectively.
Step 2: PRINT(x); becomes printf(“%d,”,x). Hence it prints ‘2’.
Step 3: PRINT(y); becomes printf(“%d,”,y). Hence it prints ‘3’.
Step 4: PRINT(z); becomes printf(“%d,”,z). Hence it prints ‘4’.
Hence the output of the program is 2, 3, 4.
Incorrect
The macro PRINT(i) print(“%d,”, i); prints the given variable value in an integer format.
Step 1: int x=2, y=3, z=4; The variable x, y, z are declared as an integer type and initialized to 2, 3, 4 respectively.
Step 2: PRINT(x); becomes printf(“%d,”,x). Hence it prints ‘2’.
Step 3: PRINT(y); becomes printf(“%d,”,y). Hence it prints ‘3’.
Step 4: PRINT(z); becomes printf(“%d,”,z). Hence it prints ‘4’.
Hence the output of the program is 2, 3, 4.
-
Question 17 of 30
17. Question
What will be the output of the program?
#include<stdio.h> #define MAX(a, b, c) (a>b ? a>c ? a : c: b>c ? b : c) int main() { int x; x = MAX(3+2, 2+7, 3+7); printf("%d\n", x); return 0; }
Correct
The macro MAX(a, b, c) (a>b ? a>c ? a : c: b>c ? b : c) returns the biggest of given three numbers.
Step 1: int x; The variable x is declared as an integer type.
Step 2: x = MAX(3+2, 2+7, 3+7); becomes,
=> x = (3+2 >2+7 ? 3+2 > 3+7 ? 3+2 : 3+7: 2+7 > 3+7 ? 2+7 : 3+7)
=> x = (5 >9 ? (5 > 10 ? 5 : 10): (9 > 10 ? 9 : 10) )
=> x = (5 >9 ? (10): (10) )
=> x = 10
Step 3: printf(“%d\n”, x); It prints the value of ‘x’.
Hence the output of the program is “10”.
Incorrect
The macro MAX(a, b, c) (a>b ? a>c ? a : c: b>c ? b : c) returns the biggest of given three numbers.
Step 1: int x; The variable x is declared as an integer type.
Step 2: x = MAX(3+2, 2+7, 3+7); becomes,
=> x = (3+2 >2+7 ? 3+2 > 3+7 ? 3+2 : 3+7: 2+7 > 3+7 ? 2+7 : 3+7)
=> x = (5 >9 ? (5 > 10 ? 5 : 10): (9 > 10 ? 9 : 10) )
=> x = (5 >9 ? (10): (10) )
=> x = 10
Step 3: printf(“%d\n”, x); It prints the value of ‘x’.
Hence the output of the program is “10”.
-
Question 18 of 30
18. Question
Point out the error in the program
#include<stdio.h> #define SI(p, n, r) float si; si=p*n*r/100; int main() { float p=2500, r=3.5; int n=3; SI(p, n, r); SI(1500, 2, 2.5); return 0; }
Correct
The macro #define SI(p, n, r) float si; si=p*n*r/100; contains the error. To remove this error, we have to modify this macro to
#define SI(p,n,r) p*n*r/100
Incorrect
The macro #define SI(p, n, r) float si; si=p*n*r/100; contains the error. To remove this error, we have to modify this macro to
#define SI(p,n,r) p*n*r/100
-
Question 19 of 30
19. Question
Point out the error in the program
#include<stdio.h> int main() { int i; #if A printf("Enter any number:"); scanf("%d", &i); #elif B printf("The number is odd"); return 0; }
Correct
The conditional macro #if must have an #endif. In this program there is no #endif statement written.
Incorrect
The conditional macro #if must have an #endif. In this program there is no #endif statement written.
-
Question 20 of 30
20. Question
Which of the following are correct preprocessor directives in C?
1: #ifdef
2: #if
3: #elif
4: #undefCorrect
The macros #ifdef #if #elif are called conditional macros.
The macro #undef undefine the previosly declared macro symbol.
Hence all the given statements are macro preprocessor directives.
Incorrect
The macros #ifdef #if #elif are called conditional macros.
The macro #undef undefine the previosly declared macro symbol.
Hence all the given statements are macro preprocessor directives.
-
Question 21 of 30
21. Question
Which of the following are correctly formed #define statements in C?
Correct
Incorrect
-
Question 22 of 30
22. Question
If the file to be included doesn’t exist, the preprocessor flashes an error message.
Correct
True, the included file does not exist it will generate the error.
Incorrect
True, the included file does not exist it will generate the error.
-
Question 23 of 30
23. Question
Preprocessor directive #undef can be used only on a macro that has been #define earlier
Correct
True, #undef can be used only on a macro that has been #define earlier
Example: #define PI 3.14
We can undefine PI macro by #undef PI
Incorrect
True, #undef can be used only on a macro that has been #define earlier
Example: #define PI 3.14
We can undefine PI macro by #undef PI
-
Question 24 of 30
24. Question
There exists a way to prevent the same file from getting #included twice in the same program.
Correct
True, We can prevent the same file from getting included again by using a preprocessor directive called #ifndef(short for “if not defined”) to determine whether we’ve already defined a preprocessor symbol called XSTRING_H. If we have already defined this symbol, the compiler will ignore the rest of the file until it sees a #endif (which in this case is at the end of the file).
#ifndef XSTRING_H
#define XSTRING_H defines the same preprocessor symbol,
Finally, the last line of the file, #endif
Incorrect
True, We can prevent the same file from getting included again by using a preprocessor directive called #ifndef(short for “if not defined”) to determine whether we’ve already defined a preprocessor symbol called XSTRING_H. If we have already defined this symbol, the compiler will ignore the rest of the file until it sees a #endif (which in this case is at the end of the file).
#ifndef XSTRING_H
#define XSTRING_H defines the same preprocessor symbol,
Finally, the last line of the file, #endif
-
Question 25 of 30
25. Question
A preprocessor directive is a message from programmer to the preprocessor.
Correct
True, the programmer tells the compiler to include the preprocessor when compiling.
Incorrect
True, the programmer tells the compiler to include the preprocessor when compiling.
-
Question 26 of 30
26. Question
Macro calls and function calls work exactly similarly.
Correct
False, A macro just replaces each occurrence with the code assigned to it. e.g. SQUARE(3) with ((3)*(3)) in the program.
A function is compiled once and can be called from anywhere that has visibility to the funciton.
Incorrect
False, A macro just replaces each occurrence with the code assigned to it. e.g. SQUARE(3) with ((3)*(3)) in the program.
A function is compiled once and can be called from anywhere that has visibility to the funciton.
-
Question 27 of 30
27. Question
A macro must always be defined in capital letters.
Correct
FALSE, The macro is case insensitive.
Incorrect
FALSE, The macro is case insensitive.
-
Question 28 of 30
28. Question
Macros have a local scope.
Correct
False, The scope of macros is globals and functions. Also the scope of macros is only from the point of definition to the end of the file.
Incorrect
False, The scope of macros is globals and functions. Also the scope of macros is only from the point of definition to the end of the file.
-
Question 29 of 30
29. Question
Every C program will contain at least one preprocessor directive.
Correct
False, the preprocessor directive is not mandatory in any c program.
Incorrect
False, the preprocessor directive is not mandatory in any c program.
-
Question 30 of 30
30. Question
Preprocessor directive #ifdef .. #else … #endif is used for conditional compilation.
Correct
True, these macros are used for conditional operation.
#if <constant-expression> #elif <constant-expression> #endif
Incorrect
True, these macros are used for conditional operation.
#if <constant-expression> #elif <constant-expression> #endif