Preprocessors
- What will be the output of the following C code?
#include <stdio.h>
#define MINIMUM 15
#if defined(MINIMUM) - (!defined(MAXIMUM))
#define MAXIMUM 115
#endif
int main()
{
printf("%d %d\n", MAXIMUM, MINIMUM);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
Compilation Error
main.c: In function ‘main’:
main.c:8:27: error: ‘MAXIMUM’ undeclared (first use in this function); did you mean ‘MINIMUM’?
printf("%d %d\n", MAXIMUM, MINIMUM);
^~~~~~~
MINIMUM
main.c:8:27: note: each undeclared identifier is reported only once for each function it appears in
- What will be the output of the following C code?
#include <stdio.h>
#define MINIMUM 25
#if defined(MINIMUM) + defined(MAXIMUM)
#define MAXIMUM 125
#endif
int main()
{
printf("%d %d\n", MAXIMUM, MINIMUM);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
125 25
- What will be the output of the following C code?
#include <stdio.h>
#define MINIMUM 10
#ifdef MINIMUM
#define MAXIMUM 110
#endif
int main()
{
printf("%d %d\n", MAXIMUM, MINIMUM);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: D
110 10
- What will be the output of the following C code?
#include <stdio.h>
#define MINIMUM 20
#if MINIMUM
#define MAXIMUM 100
#endif
int main()
{
printf("%d %d\n", MAXIMUM, MINIMUM);
return 0;
}
-
View Hint View Answer Discuss in Forum
NA
Correct Option: E
100 20
- The #else directive is used for _________.
-
View Hint View Answer Discuss in Forum
NA
Correct Option: C
Conditionally include source text if the previous #if, #ifdef, #ifndef, or #elif test fails