closepop
closepop

Would you like to submit the test?


C Language :

C Preprocessor




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

It compiles
Compiles with an warning
Not compile
Compiles and print nothing




2.
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




3.
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, %dn", i, j, k);
    return 0;
}

12,6,12
11,5,11
11,5,garbage
12,6,garbage




4.
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("%dn", a);
    return 0;
}

25
11
error
garbage value




5.
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, %dn", a, b);
    return 0;
}

9,4
27,4
27,6
error




6.
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("%dn", FUN(va1, 2));
    return 0;
}

10
20
30
40




7.
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("%dn", x);
    return 0;
}

8
9
4
7




8.
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("%dn", z);
    return 0;
}

3
4
0
no output




9.
 
What will be the output of the program?

#include<stdio.h>
#define MESS junk

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

junk
MESS
error
nothing will print




10.
    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;
}

2,3,4
2,2,2
3,3,3
4,4,4




11.
     What will be the output of the program?

#include
#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("%dn", x);
    return 0;
}

5
9
10
3+7










FreshersLive - No.1 Job site in India. Here you can find latest 2016 government as well as private job recruitment notifications for different posts vacancies in India. Get top company jobs for both fresher and experienced. Job Seekers can get useful interview tips, resume services & interview Question and answer. Practice online test free which is helpful for interview preparation. Register with us to get latest employment news/rojgar samachar notifications. Also get latest free govt and other sarkari naukri job alerts daily through E-mail.


FreshersLive - No.1 Job site in India. Here you can find latest 2016 government as well as private job recruitment notifications for different posts vacancies in India. Get top company jobs for both fresher and experienced. Job Seekers can get useful interview tips, resume services & interview Question and answer. Practice online test free which is helpful for interview preparation. Register with us to get latest employment news/rojgar samachar notifications. Also get latest free govt and other sarkari naukri job alerts daily through E-mail.