What will be the output of the following C code?
#define sqr(x) x*x
main()
{
int a1;
a1=25/sqr(5);
printf("%d",a1);
}
Answer: A
The output of the code shown above is 25. This is because the arithmetic statement takes the form of: 25/5*5 (which is equal to 1). If the macro had been defined as #define sqr(x) (x*x), the output would have been 1.
Enter details here
After preprocessing when the program is sent for compilation the macros are removed from the expanded source code.
Answer: A
No answer description available for this question.
Enter details here
What is #include directive?
Answer: A
No answer description available for this question.
Enter details here
What will be the output of the following C code?
#include
#define a 2
main()
{
int r;
#define a 5
r=a*2;
printf("%d",r);
}
Answer: A
No answer description available for this question.
Enter details here
What will be the output of the following C code?
#include
#define max 100
main()
{
#ifdef max
printf("hello");
}
Answer: D
The code shown above results in an error. This is because the preprocessor #endif is missing in the above code. If the identifier is defined, then the statements following #ifdef are executed till #endif is encountered.
Enter details here
A macro must always be defined in capital letters.
Answer: B
FALSE, The macro is case insensitive.
Enter details here
What will be the output of the following C code?
#include
#define max 100
void main()
{
#if(max)
printf("san");
#endif
printf("foundry");
}
Answer: D
The code shown above is an illustration of the preprocessor directive #if. The value of the defined identifier max is 100. On checking the condition (100510==), which is true, the statements after #if are executed till #endif is encountered. Hence the output is sanfoundry.
Enter details here
What is a preprocessor directive
Answer: C
preprocessor directive is a message from programmer to the preprocessor.
Enter details here
#include
#define square(x) x*x
int main()
{
int x;
x = 36/square(6);
printf("%d", x);
return 0;
}
Answer: B
No answer description available for this question.
Enter details here
What will be the output of the program?
#include
#define PRINT(i) printf("%d,",i)
int main()
{
int x=2, y=3, z=4;
PRINT(x);
PRINT(y);
PRINT(z);
return 0;
}
Answer: A
No answer description available for this question.
Enter details here