100 Questions
100 Questions
A.11111110
B.01111111
C.11111111
D.10000000
A.assembly language
B.nature language
C.machine language
D.advanced language
A.10.8 9 3
B.10 9 3
C.11 9 3
D.10 0.8 9
10
In C language, which one of the following operators requires its operands must
be of type int?
A.=
B./
C.%
D.*
11
Suppose int k=7, x=12; of which expression the value is 3?
A.x%=(k-k%5)
B.(x%=k)-(k%=5)
C.x%=k-k%5
D.x%=(k%=5)
12
The value of the expression 3.6-5/2+1.2+5%2 is .
A.4.8
B.3.3
C.3.8
D.4.3
13
Suppose all variables in the following expressions have been declared and
initialized, which of the following is a legal expression in C language?
A.a := b + 1
B.18.5%3
C.a = a + 7 = c + b
D.a = b = c + 2
14
15
What output does the following call of printfproduce?
17
18
19
21
Which one of the following is not a legal way to write the number 65? (Assume
that the character set is ASCII.)
A.0101
B.0b1000001
C.‘A’
D.0x41
22
23
Suppose i is a variable of type int, and its value is 10, which of the following is
the value of expression 30-i<=i<=9 ?
A.1
B.0
C.20
D.9
24
25
26
27
After the execution of the following statements:
int m1=5,m2=3;
m1>m2 ? (m1=1):(m2=-1);
, the values of m1 and m2 are respectively?
A.5 and 3
B.1 and 3
C.5 and -1
D.1 and -1
29
In C language, the rule on embedded if statement is that else is always paired
with .
A.the first if
B.the previous nearest unpaired if
C.if with the same indent
D.the nearest if
30
Which one is correct when execute the following code?
int x=0,y=0,z=0;
if (x=y+z) printf("***");
else printf("###");
A.Error while linking
B.It outputs ###
C.It outputs ***
D.Syntax error while compiling
31
When execute the following program:
#include <stdio.h>
int main()
{ int x,y;
scanf("%d%d",&x,&y);
if (x>y)
x=y;y=x;
else
x++;y++;
printf("%d,%d",x,y);
return 0;
}
Which one of the following is correct?
A.Syntax error while compiling
B.If input 4 and 3, it outputs 3 and 4
C.If input 4 and 3, it outputs 4 and 5
D.If input 3 and 4, it outputs 4 and 5
32.
If a=1, b=3, c=5, d=4,the value of x is when execute the following program.
if (a<b)
if (c<d) x=1 ;
else
if (a<c)
if (b<d) x=2 ;
else x=3 ;
else x=6 ;
else x=7 ;
A.1
B.2
C.4
D.3
33
Which one of the following is equal to the statement y=(x>0 ? 1: x<0 ? -1:0); .
A.
y=0;
if (x>=0)
if (x>0) y=1;
else y=-1;
B.
y=-1;
if (x)
if (x>0) y=1;
else if (x==0) y=0;
else y=-1;
C.
if (x>0) y=1;
else if (x<0) y=-1;
else y=0;
D.
if (x)
if (x>0) y=1;
else if (x<0) y=-1;
else y=0;
34
If int i=10; the value of i will be after executing the following code.
switch (i) {
case 9: i+=1 ;
case 10: i+=1 ;
case 11: i+=1 ;
default: i+=1 ;
}
A.12
B.11
C.13
D.10
35
C statements can be categorized into controlling statements (selection, loop, jump),
function calling statements, , empty statements and compound statements
(5 types).
36
Compound statements are statement blocks enclosed by a pair of .
37
C language does not provide input/output statement, its input/output operation is
implemented by .
38
Generally, at the beginning of a program file there should be preprocessing
directive , when calling standard formatted input/output library function.
39
When execute a switch block, the statement can make the control quit from
the switch block immediately.
41
Assuming the following statements:
char c1='1',c2='2';
c1=getchar();
c2=getchar();
putchar(c1);
putchar(c2);
If input a↙ , when run the code, ↙is used to represent Enter key, which one of the
following is correct?
A.Variable c1 is assigned the character a, and c2 remains the character 2.
B.The program will wait for the second character input by user.
C.Variable c1 is assigned the character a, and c2 remains uncertain value.
D.Variable c1 is assigned the character a, and c2 is assigned a new-line character.
42
Given the following declarations and scanf function call statements, to make the value of
a1, a2, c1, c2 to be 10, 20, A and B respectively. Which one of the following inputs is the
correct? ↙is used to represent Enter key.
int a1,a2;
char c1,c2;
scanf("%d%d",&a1,&a2);
scanf("%c%c",&c1,&c2);
A.1020AB↙
B.10 20AB↙
C.10 20 AB↙
D.10 20↙
AB↙
43
Assuming the statement scanf("a=%d,b=%d,c=%d",&a,&b,&c);To make the values of
a, b, and c to be 1, 3, 2 respectively, which of the following input is correct? ↙is used to
represent Enter key and└┘ is used to represent space.
A.132↙
B.1,3,2↙
C.a=1,b=3,c=2↙
D.a=1└┘b=3└┘c=2↙
44
If the variable x is of type double, which one of the following statements is right?
A.scanf("%f",&x);
B.scanf("%lf",&x);
C.scanf("%f",x);
D.scanf("%5.1f",&x);
45
What is the output of the following code? └┘ is used to represent space.
float x=-1023.012;
printf("%8.3f,",x);
printf("%10.3f",x);
A.1023.012,-1023.012
B.–1023.012,-1023.012
C.1023.012,└┘-1023.012
D.–1023.012,└┘-1023.012
46
int x=13,y=5;
printf("%d",x%=(y/=2));
A.0
B.3
C.1
D.2
47
What is the output of the following code?
int x='f';
printf("%c",'A'+(x-'a'+1));
A.H
B.I
C.J
D.G
48
If we declared int a=1234;, what is the result when executing the statement
printf("%2d",a);?
A.1234
B.12
C.34
D.Error
49
Given the declarations: int a=7, b=8; what is the result when execute printf("%d, %d",
(a+b,a), (b,a+b));?
A.15, 7
B.7, 15
C.8, 15
D.Error
50
What is the result when execute printf("a\bre\'hi\'y\\\bou");?
A.abre'hi'y\bou
B.a\bre\'hi\'y\\\bou
C.re'hi'you
D.abre'hi'ybou
51
What is the output of the following code?
int x=102,y=012;
printf("%2d,%2d",x,y);
A.102,12
B.10,01
C.102,10
D.02,12
52
What is the output of the following statements?
int m=0256,n=256;
printf("%o %o",m,n);
A.400 400
B.0256 0400
C.0256 256
D.256 400
53
What is the output of the following code?
int a;
char c=10;
float f=100.0;
double x;
a=f/=c*=(x=6.5);
printf("%d %d %3.1f %3.1f",a,c,f,x);
A.1 65 1 6.5
B.2 65 1.5 6.5
C.1 65 1.0 6.5
D.1 65 1.5 6.5
54
What is the output of the following code?
char a='1',b='2';
printf("%c, ",b++);
printf("%d",b-a);
A.3, 2
B.50, 2
C.2, 50
D.2, 2
55
Execute the following statements, if input 12345678↙,what is the output? ↙is used to
represent Enter.
int a , b ;
scanf("%2d%*2d%3d",&a,&b);
printf("%d",a+b);
A.46
B.Error
C.579
D.5690
56
The while statement in the following code loops for times.
int i=0;
while (i<10) {
if (i<1) continue;
if (i==5) break;
i++;
}
A.1
B.6
C.infinite
D.10
57
The following code .
x=-1;
do{
x=x*x;
}while (!x);
A.is an infinite loop.
B.loops for one time.
C.loops for two times.
D.has syntax error.
58
Which one of the following statements is correct?
A.do statement can only be terminated by break statement.
B.do statement will be terminated when its controlling expression is zero.
C.do statement will be terminated when its controlling expression is non-zero.
D.do statement cannot be replaced by the other iteration statements.
59
Assume the following code:
int n=0,p;
do {
scanf("%d",&p);
n++;
} while (p!=12345 && n<3);
When , the loop will terminate.
A.p is equal to 12345 and n is not less than 3.
B.p is not equal to 12345 and n is less than 3.
C.p is equal to 12345 or n is not less than 3.
D.p is not equal to 12345 or n is less than 3.
60
Given the following for statement:
int i,k;
for (i=0,k=-1; k=1 ; i++,k++ ) printf("***");
Which one of the following conclusions is correct?
A.The above for statement contains illegal expression.
B.The above for statement never loops.
C.The above for statement is an infinite loop.
D.The above for statement loops for 1 time.
61
The loop times of the following for statement are .
for (i=2; i==0; ) printf("%d",i--);
A.2
B.0
C.1
D.Infinite
62
What is the output of the following program?
#include <stdio.h>
int main()
{ int i,sum;
for(i=1;i<6;i++)
sum+=i;
printf("%d",sum);
return 0;
}
A.15
B.unpredictable
C.0
D.14
63
Assume s, a, b, c are declared as integers, and a, c have been assigned values ( c>0 ),
s=a;
for(b=1; b<=c; b++)
s=s+1;
Which one of the following is equal to the above code?
A.s=a+b;
B.s=s+c;
C.s=a+c;
D.s=b+c;
64
What is the output of the following program?
#include <stdio.h>
int main()
{ int i=0,s=0;
for (;;) {
if(i==3||i==5) continue;
if (i==6) break;
i++; s+=i;
};
printf("%d",s);
return 0;
}
A.21
B.10
C.The program contains an infinite loop, it will not output anything.
D.13
65
If the variables i and p have been declared and initialized correctly, which one of the
following cannot calculate 5! ?
A.
i=1;
p=1;
do{
p*=i;
i++;
}while(i<=5);
B.
for(i=1,p=1;i<=5;i++){
p*=i;
}
C.
i=1;
p=1;
while(i<=5)
{p*=i;
i++;
}
D.
for(i=1;i<=5;i++)
{ p=1;
p*=i;
}
66
What is the output of the following program?
#include <stdio.h>
int main()
{ int k=0,m=0,i,j;
for (i=0; i<2; i++) {
for (j=0; j<3; j++)
k++ ;
k-=j ;
}
m = i+j ;
printf("k=%d,m=%d",k,m);
return 0;
}
A.k=1,m=3
B.k=1,m=5
C.k=0,m=5
D.k=0,m=3
67
Which one of the following is not correct?
A.The statements in C language, except compound statements, must be ended with
semicolons.
B.Compound statements are regarded as one single statement in syntax.
C.An empty statement does not affect the program in any location.
D.An assignment statement can be made by adding a semicolon at the end of the
assignment expression.
68
Assume the following program fragment:
int k=2;
while (k=0)
{
printf("%d",k) ;
k-- ;
}
Which one of the following is correct?
A.The loop never runs.
B.The loop runs for only one time.
C.while statement loops for 10 times.
D.The loop is infinite.
69
Which one of the following function definitions is right?
A.
double f(int x,int y)
{ z=x+y;
return z ;
}
B.
double f(int x,y)
{ double z=x+y ;
return z ;
}
C.
double f(int x,int y)
{ double z ;
z = x+y ;
return z ;
}
D.
double f(x,y)
{ int x, y ;
double z ;
z=x+y;
return z ;
}
70
Assume a function definition as follows:
fun(int a,float b) {
return a+b;
}
, which one of the following is the return type of this function in C89?
A.int
B.unpredictable
C.void
D.float
71
Which one of the following determines the return type of a function in C language?
A.Compiler
B.The return type specified by function definition
C.The expression type in the return statement
D.The calling function
72
Which one of the following statements about function return type is wrong?
A.Function return type can be void.
B.Function return type can be char.
C.Function return type can be int.
D.Function return type can be array.
73
Given a function definition as follows:
void f(char ch, float x ) { ...... }
, which one of the following function call statements is right?
A.f(32,32);
B.t=f('D',16.5);
C.f('65',2.8);
D.f("abc",3.0);
74
Assume a program defines a function as follows:
double f(double a,double b)
{ return (a+b); }
, the definition is placed after calling f. Therefore f should be declared before the calling.
Which one of the following prototypes is wrong?
A.double f(double a,B);
B.double f(double b,double A);
C.double f(double x,double y);
D.double f(double,double);
75
Assume all variables in the following choices have been declared correctly and the
function fun uses a return statement to return a value, which one of the following is
wrong?
A.
int main()
{…… x=fun(2,10); ……}
float fun(int a,int b){……}
B.
float fun(int,int);
int main()
{…… x=fun(2,10); ……}
float fun(int a,int b){……}
C.
int main()
{float fun(int i,int j);
…… x=fun(i,j); ……}
float fun(int a,int b){……}
D.
float fun(int a,int b){……}
int main()
{…… x=fun(i,j); ……}
76
Which one is the output of the following program?
#include <stdio.h>
void F(int x) { return (3*x*x); }
int main(){
printf("%d",F(3+5));
return 0;
}
A.192
B.Compiling Error
C.29
D.25
77
Which one is the output of the following program?
#include <stdio.h>
void fun(int x, int y, int z)
{ z=x*x+y*y; }
int main()
{
int a=31;
fun(5,2,a);
printf("%d",a);
return 0;
}
A.unpredictable
B.0
C.29
D.31
78
Assume a function definition as follows:
int data() {
float x=9.9;
return(x);
}
, when call this function, it will return _____.
79
If a function directly or indirectly calls itself, this function is a function.
82
Assuming the macro definition #define MOD(x,y) x%y, what is the result of the following
code?
int z,a=15;
float b=100;
z=MOD(b,a);
printf("%d",z++);
A.Syntax error
B.11
C.6
D.10
Chapter 7 Quiz I - Array (13)
83
Assume a declaration int a[10]; , which one of the following can reference the element in
a correctly?
A.a(5)
B.a[-10]
C.a[10]
D.a[3]
84
Which one of the following initialization is correct for the 2-D array a?
A.int a[][]={1,2,3,4,5,6};
B.int a[2][]={1,2,3,4,5,6};
C.int a[][3]={1,2,3,4,5,6};
D.int a[2,3]={1,2,3,4,5,6};
85
Which one of the following initializations is correct for the 2-D array a?
A.int a[][3]={{1,0,1},{},{1,1}} ;
B.int a[][3]={{1,2,3},{4,5,6}} ;
C.int a[2][4]={{1,2,3},{4,5},{6}} ;
D.int a[2][]={{1,0,1},{5,2,3}} ;
86
Assume the declaration int a[3][4]; which one of the following can index the element in a
correctly?
A.a[3][3]
B.a[0][0]
C.a[2][4]
D.a[3][4]
87
Assume the declaration intb[][3]={1,2,3,4,5,6,7}; the length of the first dimension of array
b is .
A.2
B.uncertain
C.4
D.3
88
Assume the declaration int a[3][4]={0}; which one of the following statements is correct?
A.It is a wrong statement.
B.Only the element a[0][0] is initialized to 0.
C.Each element in a is initialized but not to 0.
D.Each element in a is initialized to 0.
89
Assume the declaration int a[][4]={0,0}; which one of the following statements is wrong?
A.Only the elements a[0][0] and a[0][1] are initialized to 0, while the others are not.
B.The array has 1 row, because the quotient is 0 when divide the number of initial values
by the second dimension size of array a.
C.The length of the first dimension of the 2-D array a is 1.
D.Each element in a is initialized to 0.
90
What is the output of the following code?
int k,a[3][3]={1,2,3,4,5,6,7,8,9};
for (k=0;k<3;k++)
printf("%d",a[k][2-k]);
A.3 6 9
B.1 5 9
C.1 4 7
D.3 5 7
91
.In C language, the array index starts from , and it cannot be negative.
92
Assuming the definition: int a[3][4]={{1,2},{0},{4,6,8,10}}; the value of a[1][2]
is after the initialization.
94
Assuming char x[]="12345",y[]={'1','2','3','4','5','\0'}; which one of the following
statements is correct?
A.x is shorter than y.
B.x is longer than y.
C.The lengths of array x and y are equal.
D.Arrays x and y share the same memory area.
95
Given two character arrays a and b, which one of the following statements is correct?
A.scanf("%s%s",&a,&b);
B.scanf("%s%s",a,b);
C.gets("a");gets("b");
D.gets(a,b);
98
Given int a=3,b,*p=&a;which one of the following statements doesn’t assign the value 3
to b?
A.b=a;
B.b=*p;
C.b=*a;
D.b=*&a;
99
Assume p1 and p2 are pointers to the same string; c is a character variable, which one of
the following assignment statements is incorrect?
A.c=*p1*(*p2);
B.p2=c;
C.c=*p1+*p2;
D.p1=p2;
Chapter 8 Quiz II