Macro

1. What is output?

#include <stdio.h>
#include <conio.h>

#define x 5+2

void main()
{
    int i;
    i = x*x*x;
    printf("%d", i);
    getch();
}

A. 21
B. 27
C. Complier Error
D. Another

Đáp án
B

2. What is output?

#include <stdio.h>
#include <conio.h>

#define call(x,y) x##y

void main()
{
    int x = 5, y = 10, xy = 20;
    printf("%d", xy + call(x, y));
    getch();
}

A. 530
B. 70
C. 40
D. Complier Error
Đáp án

C

3. What is output?

#include <stdio.h>
#include <conio.h>

#if X == 3
#define Y 3
#else
#define Y 5
#endif

void main()
{
    printf("Y = %d", Y);
    getch();
}

A. Y = 3
B. Y = 5
C. Garbage value
Đáp án

B

 

4. What is output?

#include <stdio.h>
#include <conio.h>

#define X 3
#if !X
printf("C/C++");
#else
printf("Java");
#endif

void main()
{
    getch();
}

A. C/C++
B. Java
C. Complier error
Đáp án

C

5. What is output?

#include <stdio.h>
#include <conio.h>

#define ISEQUAL(X, Y) X == Y

void main()
{
#if ISEQUAL(X, 0)
    printf("C/C++");
#else
    printf("Java");
#endif
    getch();
}

A. C/C++
B. Java
C. Complier error
Đáp án

C

 

6. What is output?

#include <stdio.h>
#include <conio.h>

#define SQUARE(x) x*x

void main()
{
    int x;
    x = 36 / SQUARE(6);
    printf("%d", x);
    getch();
}

A. 1
B. 36
C. 6
Đáp án

B

7. What is output?

#include <stdio.h>
#include <conio.h>

#define a 10

void main()
{
    printf("%d ", a);
#define a 50
    printf("%d ", a);
    getch();
}

A. 10 50
B. 10 10
C. 50 50
Đáp án

A

8. What is output?

#include <stdio.h>
#include <conio.h>

#define MAX 1000

void main()
{
    int MAX = 100;
    printf("%d ", MAX);
    getch();
}

A. 1000
B. 100
C. Complier error
Đáp án

C

9. What is output?

#include <stdio.h>
#include <conio.h>

#define PRINT(i, limit) do \
                        { \
                        if (i++ < limit) \
                            { \
                            printf("vncoding"); \
                            continue; \
                            } \
                        }while(1)

void main()
{
    PRINT(0, 3);
    getch();
}

A. ‘vncoding’ is printed 3 times
B. ‘vncoding’ is printed 2 times
C. Complier error
Đáp án

C

Be the first to comment

Leave a Reply