Time left:

[All Quizzes] → [Programming With C] → [Macro Processing]


1. ► What is the output of the following program?

1
2
3
4
5
6
7
8
#define MAX(x, y) x>y ? 1: 0

int main()
{
    int i = 9;

    printf("%d", MAX(10, i) + 1);
}
A.
B.
C.
D.

2. ► What is the output of the following program?

1
2
3
4
5
6
7
8
9
#define DIGIT1 110
#define DIGIT2 20

int main()
{
    char *s = "DIGIT1 > DIGIT2";

    printf("%s", s);
}
A.
B.
C.
D.

3. ► Compiler gives error while compiling the following program. Why?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#define INCR(i, j) \
{ i++; \
j++; }

int main()
{
    int i = 10, j = 20;

    if (1)
        INCR(i, j);
    else
        INCR(j, i);
    printf("%d", i);
}
A.
B.
C.
D.

4. ► What is the output of the following program?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
#define INCR(i, j) \
i++; \
j++

int main()
{
    int i = 10, j = 20;

    if (1)
        INCR(i, j);
    else
        INCR(j, i);
    printf("%d", i);
}
A.
B.
C.
D.

5. ► What is the output of the following program?

1
2
3
4
5
6
7
8
9
#define DIGIT1 110
#define DIGIT2 20

int main()
{
    int i = DIGIT1 > DIGIT2;

    printf("%d", i);
}
A.
B.
C.
D.

6. ► What is the output of the following program?

1
2
3
4
5
6
7
8
#define MACRO1(arg) #arg
#define MACRO2 20
#define MACRO3 MACRO1(110)

int main()
{
    printf("%d", MACRO3);
}
A.
B.
C.
D.

7. ► What is the output of the following program?

1
2
3
4
5
6
7
8
#define MAX(x, y) (x>y ? 1: 0)

int main()
{
    int i = 20;

    printf("%d", MAX(10, i));
}
A.
B.
C.
D.

8. ► Compiler can perform typechecking on macros.

A.
B.

9. ► Which of the following option is used to pass on macro value on command line?

A.
B.
C.
D.

10. ► What is the output of the following program?

1
2
3
4
5
6
#define STR(mystr) mystr##_s

int main()
{
    printf("%s", STR(name));
}
A.
B.
C.
D.

11. ► What is the output of the following program?

1
2
3
4
5
6
7
8
9
10
11
12
13
#define ARRAY

int main()
{
    int i = 20;

#if defined ARRAY
    i++;
#else
    i--;
#endif
    printf("%d", i);
}
A.
B.
C.
D.

12. ► Which of the following tools expands macros.

A.
B.
C.
D.

13. ► Macros are language constructs.

A.
B.

14. ► Inline functions are preferred over macros.

A.
B.

15. ► What is the output of the following program?

1
2
3
4
5
6
7
8
#define MACRO1(arg) #arg
#define MACRO2 20
#define MACRO3 MACRO1(110)

int main()
{
    printf("%d", MACRO3 > MACRO2);
}
A.
B.
C.
D.

16. ► #include can occur only at the top of the file.

A.
B.

17. ► What is the output of the following program?

1
2
3
4
5
6
7
8
#define INCR(x)  x + 1

int main()
{
    int i = INCR(10) * 2;

    printf("%d", i);
}
A.
B.
C.
D.

18. ► A debugger can set the breakpoint within macro.

A.
B.

19. ► Which of the following option helps in viewing exapanded macros?

A.
B.
C.
D.

20. ► Each macro starts with char ‘#’ .

A.
B.


© 2016 VirtuQ™ Education All right reserved. | Terms of Use | Privacy Policy