Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 86
1-
Point out the correct statements are correct about the program below?
#include<stdio.h>
int main()
{
char ch;
while(x=0;x<=255;x++)
printf("ASCII value of %d character %c\n", x, x);
return 0;
}
A -
The code generates an infinite loop
B -
The code prints all ASCII values and its characters
C -
Error: x undeclared identifier
D -
Error: while statement missing
2-
Which of the following is the correct usage of conditional operators used in C?
A -
a>b ? c=30 : c=40;
B -
a>b ? c=30;
C -
max = a>b ? a>c?a:c:b>c?b:c
D -
return (a>b)?(a:b)
3-
What will be the output of the program?
#include<stdio.h>
#include<math.h>
int main()
{
float n=1.54;
printf("%f, %f\n", ceil(n), floor(n));
return 0;
}
A -
2.000000, 1.000000
B -
1.500000, 1.500000
C -
1.550000, 2.000000
D -
1.000000, 2.000000
4-
What will be the output of the program?
#include<stdio.h>
int main()
{
float d=2.25;
printf("%e,", d);
printf("%f,", d);
printf("%g,", d);
printf("%lf", d);
return 0;
}
A -
2.2, 2.50, 2.50, 2.5
B -
2.2e, 2.25f, 2.00, 2.25
C -
2.250000e+000, 2.250000, 2.25, 2.250000
D -
Error
5-
If a function contains two return statements successively, the compiler will generate warnings. Yes/No ?
A -
Yes
B -
No
6-
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
7-
What will be the output of the program ?
#include<stdio.h>
int main()
{
float arr[] = {12.4, 2.3, 4.5, 6.7};
printf("%d\n", sizeof(arr)/sizeof(arr[0]));
return 0;
}
A -
5
B -
4
C -
6
D -
7
8-
s there any difference int the following declarations?
int fun(int arr[]);
int fun(int arr[2]);
A -
Yes
B -
No
9-
What will be the output of the program (Turbo C in 16 bit platform DOS) ?
#include<stdio.h>
#include<string.h>
int main()
{
char *str1 = "India";
char *str2 = "BIX";
char *str3;
str3 = strcat(str1, str2);
printf("%s %s\n", str3, str1);
return 0;
}
A -
IndiaBIX India
B -
IndiaBIX IndiaBIX
C -
India India
D -
Error
10-
Which of the following statements correct about the below program?
#include<stdio.h>
int main()
{
union a
{
int i;
char ch[2];
};
union a u1 = {512};
union a u2 = {0, 2};
return 0;
}
1: u2 CANNOT be initialized as shown.
2: u1 can be initialized as shown.
3: To initialize char ch[] of u2 '.' operator should be used.
4: The code causes an error 'Declaration syntax error'
A -
1, 2
B -
2, 3
C -
1, 2, 3
D -
1, 3, 4
[Người đăng: Thành Lãm - ST]