Trắc Nghiệm Ngôn Ngữ Lập Trình C ( English ) - Bài 70
1-
How many times the while loop will get executed if a short int is 2 byte wide?
#include<stdio.h>
int main()
{
int j=1;
while(j <= 255)
{
printf("%c %d\n", j, j);
j++;
}
return 0;
}
A -
Infinite times
B -
255 times
C -
256 times
D -
254 times
2-
Which of the following errors would be reported by the compiler on compiling the program given below?
#include<stdio.h>
int main()
{
int a = 5;
switch(a)
{
case 1:
printf("First");
case 2:
printf("Second");
case 3 + 2:
printf("Third");
case 5:
printf("Final");
break;
}
return 0;
}
A -
There is no break statement in each case.
B -
Expression as in case 3 + 2 is not allowed.
C -
Duplicate case case 5:
D -
No error will be reported.
3-
Point out the error, if any in the program.
#include<stdio.h>
int main()
{
int P = 10;
switch(P)
{
case 10:
printf("Case 1");
case 20:
printf("Case 2");
break;
case P:
printf("Case 2");
break;
}
return 0;
}
A -
Error: Constant expression required at line case P:
B -
Error: No default value is specified
C -
Error: There is no break statement in each case.
D -
No error will be reported.
4-
What will be the output of the program?
#include<stdio.h>
int main()
{
int i=2;
printf("%d, %d\n", ++i, ++i);
return 0;
}
A -
3, 4
B -
4, 3
C -
4, 4
D -
Output may vary from compiler to compiler
5-
In the expression a=b=5 the order of Assignment is NOT decided by Associativity of operators
A -
True
B -
False
6-
What is the notation for following functions?
1. int f(int a, float b)
{
/* Some code */
}
2. int f(a, b)
int a; float b;
{
/* Some code */
}
A -
1. KR Notation 2. ANSI Notation
B -
1. Pre ANSI C Notation 2. KR Notation
C -
1. ANSI Notation 2. KR Notation
D -
1. ANSI Notation 2. Pre ANSI Notation
7-
How many times the program will print "IndiaBIX" ?
#include<stdio.h>
int main()
{
printf("IndiaBIX");
main();
return 0;
}
A -
Infinite times
B -
32767 times
C -
65535 times
D -
Till stack overflows
8-
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("%d\n", a);
return 0;
}
A -
11
B -
25
C -
Error
D -
Garbage value
9-
A preprocessor directive is a message from programmer to the preprocessor.