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", x, y);
    return 0;
}

It compiles
Compiles with an warning
Not compile
Compiles and print nothing
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", i, j, k);
    return 0;
}

12, 6, 12
11, 5, 11
11, 5, Garbage
12, 6, Garbage
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;
}

26250.00 7500.00
Nothing will print
Error: Multiple declaration of si
Garbage values
Which of the following are correct preprocessor directives in C?
1: #ifdef
2: #if
3: #elif
4: #undef

1, 2
4
1, 2, 4
1, 2, 3, 4
If the file to be included doesn't exist, the preprocessor flashes an error message.

True
False
Will the program compile successfully?
#include<stdio.h>
#define X(4+Y)
#define Y(X+3)

int main()
{
    printf("%d", 4*X+2);
    return 0;
}

Yes
No
In which stage the following code
#include<stdio.h>
gets replaced by the contents of the file stdio.h

During editing
During linking
During execution
During preprocessing
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;
}

Result = -100.000000
Result = -25.000000
Result = 0.000000
Result = 100.000000
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;
}

Error: unexpected end of file because there is no matching #endif
The number is odd
Garbage values
None of above
Which of the following are correctly formed #define statements in C?

#define CUBE (X) (X*X*X);
#define CUBE(x) (X*X*X)
#define CUBE(X)(X*X*X)
#define CUBE(X) {X*X*X}
Preprocessor directive #undef can be used only on a macro that has been #define earlier

True
False
Would the following typedef work?
typedef #include l;

Yes
No
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", a);
    return 0;
}

25
11
Error
Garbage value
There exists a way to prevent the same file from getting #included twice in the same program.

True
False
Will the program compile successfully?
#include<stdio.h>

int main()
{
    printf("Astiwz" "QUIZ");
    return 0;
}

Yes
No
What will be the output of the program?
#include<stdio.h>
#define JOIN(s1, s2) printf("%s=%s %s=%s ", #s1, s1, #s2, s2);
int main()
{
    char *str1="Astiwz";
    char *str2="QUIZ";
    JOIN(str1, str2);
    return 0;
}

str1=ASTIWZ str2=QUIZ
str1=Astiwz str2=QUIZ
str1=Astiwz str2=ASTIWZ
Error: in macro substitution
A preprocessor directive is a message from programmer to the preprocessor.

True
False
It is necessary that a header files should have a .h extension?

Yes
No
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", a, b);
    return 0;
}

9, 4
27, 4
27, 6
Error
Macro calls and function calls work exactly similarly.

True
False
Will the program compile successfully?
#include<stdio.h>

int main()
{
    #ifdef NOTE
        int a;
        a=10;
    #else
        int a;
        a=20;
    #endif
    printf("%d", a);
    return 0;
}

Yes
No
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;   [UPDATE THIS]
    PRINT(x);
    PRINT(y);
    PRINT(z);
    return 0;
}

int=2, int=3, int=4
int=2, int=2, int=2
int=3, int=3, int=3
int=4, int=4, int=4
A macro must always be defined in capital letters.

True
False
Will the following program print the message infinite number of times?
#include<stdio.h>
#define INFINITELOOP while(1)

int main()
{
    INFINITELOOP
    printf("ASTIWZ");
    return 0;
}

Yes
No
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", a, b);
    return 0;
}

a = 10, b = 12
a = 12, b = 10
Error: Declaration not allowed in macro
Error: Undefined symbol 't'
Macros have a local scope.

True
False
Will it result in to an error if a header file is included twice?

Yes
No
It is compiler dependent.
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", FUN(va1, 2));
    return 0;
}

10
20
1020
12
Every C program will contain at least one preprocessor directive.

True
False
What will be the output of the program?
#include<stdio.h>
#define FUN(arg) do
                 {
                    if(arg)
                        printf("ASTIWZ...", "");
                  }while(--i)

int main()
{
    int i=2;
    FUN(i<3);
    return 0;
}

ASTIWZ...
ASTIWZ...
ASTIWZ
ASTIWZ... ASTIWZ...
Error: cannot use control instructions in macro
No output
Preprocessor directive #ifdef .. #else ... #endif is used for conditional compilation.

True
False
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", x);
    return 0;
}

8
9
6
5
Macros with arguments are allowed

True
False
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", z);
    return 0;
}

3
4
0
No output
In a macro call the control is passed to the macro.

True
False
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", opername);
    return 0;
}

Error: in macro substitution
Error: invalid reference 'x' in macro
print 'multiply'
No output
A header file contains macros, structure declaration and function prototypes.

True
False
What will be the output of the program?
#include<stdio.h>
#define MESS junk

int main()
{
    printf("MESS");
    return 0;
}

junk
MESS
Error
Nothing will print
The preprocessor can trap simple errors like missing declarations, nested comments or mismatch of braces.

True
False
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;
}

2, 3, 4
2, 2, 2
3, 3, 3
4, 4, 4
A preprocessor directive is a message from compiler to a linker.

True
False
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", x);
    return 0;
}

5
9
10
3+7
Once preprocessing is over and the program is sent for the compilation the macros are removed from the expanded source code.

True
False