I.True/False
1.( F)Identifiers consist of letters and digits in any order, but must be in lowercase.
2.(T)We create modular programs because they are easier to develop, correct and modify.
3.(F)All computers use twice the amount of storage for double precision than floating point data type
4.(F)Static variable is not created and destroyed each time the function is called, it is the default storage class
used by C.
5.(T)A compound statement may be used anywhere in C program in place of a single statement.
6.(F)In C language, all operators are binary operator which connecting tow operands side-by-side.
7.(T)The Escape Sequence is a combinations of a backslash (\) and a character that tells the compiles to
escape from the ways these character would be normally interpreted
8.(T)Extern storage class is to extend the scope of a global variable beyond its normal boundary-file. it does
not cause the creation of a new variable.
9.(F)After defined, the symbolic names can be used in any statement and the program can change the value
of the symbolic names.
10.(T)The mistake of u sing the assignment operator”=” in place of the relational operator”==” results in a
invalid C expression
II.Choice
11.(C)For the algebraic expression 3ae/bc, which of the following C expression is invalid
A) a/b/c*e*3 B) 3*a*e/b/c
C) 3*a*e/b*c D) a*e/c/b*3
12.(D)For the declarations: char w; int x; float y; double z; the data type of the value of w*x+z-y is
A) float B) char
C) int D) double
13.(B)For following declaration, which expression will not result in 3 ?
int x[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}, *p1 ;
A) x[3] B) p1 = x +3, *p1++
C) p1 = x +2, *( p1++ ) D) p1 = x +2, *++p1
14.(A)Which one is not endless loop?
A) for (y = 0, x = 1 ; x > ++y ; x = i++ ) i = x ;
B) for ( ; ; x ++ = i ) ;
C) while (1) {x ++;}
D) for ( i =10 ; ; i--) sum += i ;
15.(B)The result of the following program is
main()
{ int a = -2, b
do
{ b = ++a;
if (!b) printf(“#”);
else printf(“*”);
}while(a<1)
}
A}#*# B} *#*
C)### D) ***
16.(D)Which one of the following functions is valid ?
A) double fun ( int x , int y )
{ z = x + y ; return z ;}
B) fun ( int x , y )
{ int z ;
return z ;}
C) fun ( x , y )
{ int x ,y ; double z ;
z = x + y ; return z ;}
D) double fun ( int x , int y )
{ double z ;
z = x + y ; return z ;}
17.(D)In a source codes file of C language, if a variable can only be used by all functions with the file itself,
the storage class of the variable is
A) extern B) register
C) auto D) static
18.(B)The C programming language the symbol “= =”is
A) rational operator B) logical operator
C) conditional operator D) assignment operator
19.(D)For the definition statement: double s = 123.5; , which one is the correct output statement?
A) printf(“s=%d ”, s); B) printf(“s=%ld ”, s);
C) printf(“s=%f ”, s); D) printf(“s=%lf ”, s);
20.( C)Which of the following expressions will result in 0?
A) 3%5 B) 3/5.0
C) 3>5 D) 3<5
III.F ill in the blanks in each program to implement the purpose according to the description Description#1:The following program can accept elements of an array from the keyboard, and find the maximum element and corresponding index in the array.
main()
{ int x[10], *p1, *p2, k;
for(k = 0; k < 10; k++) scanf("%d", x+k);
for(p1 = x, p2 = x; p1-x < 10; p1++ )
if(*p1 > * p2) p2 = 【21】 ;
printf("MAX = %d, INDEX = %d\n", *p2,【22】);
}
21.A) p1 B) p2[p1] C) x[p2] D) x – p1
22.A) p1– x B) p1 C) p2 – x D) x – p2
Description#2: For each x, the program will calculate a corresponding y according to the relationship of x and y
main()
{ int x, y;
scanf(“%d”, &x);
if(【23】 ) y = x * (x + 2);
else if(【24】 ) y = 2 * x;
else if(x <= -1) y = x - 1;
else 【25】;
if(y != -1) printf("%d", y);
else printf("error");
}
23.A) x > 2 | | x <= 10 B) x > 2 && x <= 10
C) x < 2 && x <= 10 D) x < 2 | | x >= 10
24.A) x < -1 | | x >= 2 B) x > -1 | | x <= 2
C) x > -1 && x <= 2 D) x > -1 ^ ^ x <= 2
25.A) y = -1 B) y = 0 C) x = 0 D) x = -1
IV.(1)What is the purpose of the following program?
#include
#define N 10
main()
{
int t, i, j, a[N+1] ;
printf(“please input 10 integers:”);
for (i=1; i<=N; i++)
scanf(“%d”, &a[i]);
printf(“\n”);
for (i=1; i<=N-1; i++)
{ for (j=1; j<=N-i; j++)