Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 22
1-
|
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;
}
|
|
A -
|
2, 3, 4,
|
|
B -
|
2, 2, 2,
|
|
C -
|
3, 3, 3,
|
|
D -
|
4, 4, 4,
|
2-
|
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\n", x);
return 0;
}
|
|
A -
|
5
|
|
B -
|
9
|
|
C -
|
10
|
|
D -
|
3+7
|
3-
|
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;
}
|
|
A -
|
26250.00 7500.00
|
|
B -
|
Nothing will print
|
|
C -
|
Error: Multiple declaration of si
|
|
D -
|
Garbage values
|
4-
|
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;
}
|
|
A -
|
Error: unexpected end of file because there is no matching #endif
|
|
B -
|
The number is odd
|
|
C -
|
Garbage values
|
|
D -
|
None of above
|
5-
|
Which of the following are correct preprocessor directives in C?
1: #ifdef
2: #if
3: #elif
4: #undef
|
|
A -
|
1, 2
|
|
B -
|
4
|
|
C -
|
1, 2, 4
|
|
D -
|
1, 2, 3, 4
|
6-
|
Which of the following are correctly formed #define statements in C?
|
|
A -
|
#define CUBE (X) (X*X*X);
|
|
B -
|
#define CUBE(x) (X*X*X)
|
|
C -
|
#define CUBE(X)(X*X*X)
|
|
D -
|
#define CUBE(X) {X*X*X}
|
7-
|
If the file to be included doesn't exist, the preprocessor flashes an error message.
|
|
A -
|
True
|
|
B -
|
False
|
8-
|
Preprocessor directive #undef can be used only on a macro that has been #define earlier
|
|
A -
|
True
|
|
B -
|
False
|
9-
|
There exists a way to prevent the same file from getting #included twice in the same program.
|
|
A -
|
True
|
|
B -
|
False
|
10-
|
A preprocessor directive is a message from programmer to the preprocessor.
|
|
A -
|
True
|
|
B -
|
False
|
[Người đăng: Thành Lãm - ST]
|