Computer Foundation and Programming Test Questions and Answers
1. Multiple choice questions (there are 20 small questions in this big question, and each small question 1 point, totaling 20 points). Only one of the four options listed in each small question meets the requirements of the topic. Please put a letter before the correct option in brackets after the question.
1.I/O device refers to the computer ().
A. storage devices
B. input and output equipment
C. controller
D. arithmetic unit
2. Memory with read-only function refers to ()
I. ROM
B. memory
C. hard disk
CD
3. The basic unit of C language source program is ()
A. process
B, function
C. subroutine
D. statement
4. When the string constant "CHINA" is stored in memory, the number of bytes is ().
Answer, 5
b,6
c,7
d,8
5.set int p,q; The following incorrect statement is ()
a、p*=3
b、p/=q
c、p+=3
d、p & amp& amp=q
6. if a= 1, b=2, c=3 and d=4, then the expression A >;; b? A: About 1
b、2
c、3
d、4
7. The running result of the following program segment is ()
Master ()
{Int a= 1 1,b = 10;
a-= b+ 1;
printf("%dn ",a);
}
a、 1
b、0
c、2
d、5
8. The output result after executing the following program segment is ()
int I =- 1;
If (I < = 0) printf ("* * * * n");
else printf(" % % % % n ");
a 、***C
b 、%%%
C 、%%%C
d、****
9. If the variables used are defined correctly, the output of the following program segment is ().
a = 10; b = 50c = 30
If (a & gtb)a=b
b = c; c=a
printf("a=%d,b=%d,c=%dn ",a,b,c);
a、a= 10,b=50,c= 10
b、a= 10,b=30,c= 10
c、a=50,b=30,c= 10
d、a=50,b=3,c=50
10. The cycle number of the following cycles is ()
int k = 2;
while(k=0)printf("%d ",k);
k-; printf("n ")
First, infinite times
B, 0 times
C, 1 time
D, 2 times
1 1. Among the following options, the program segment that does not constitute an infinite loop is ().
a、int I = 100;
while( 1)
{ I = i0+ 1;
If (i> 100) is broken;
}
b、for(; ; )
c、int k = 1000;
do(++k; )while(k & gt; = 10000);
d、int s = 36
while(s); -s;
12. If there are the following definitions and statements and 0
int a[]={0, 1,2,3,4,5,6,7,8,9},*p,I;
p=a
a 、*(a+i)
B, A [C]
c、p+i
d 、* & amp; a[i])
13. Among the following statements, it is () that can correctly assign the string "Boy" completely.
a、char s[3]={'B ',' o ',' y ' };
b、char s[]= " Boy ";
c、char s[3]= { " Boy " };
d、char s[3];
s[0]= ' B '; s[ 1]= ' o '; s[2]='y '
14. The output of the following program segment is ()
char arr[]= " ABCD ";
char * ptr
for(ptr = arr; ptrprintf("%sn ",ptr);
a、ABCD
B,
A
C,
D
d、
Accelerated business collection and delivery system (adopted by the United States post office)
B
C
BCD
C
B
laser record
D
A
D
15. The following statement is incorrect ()
A. the source file consists of one or more functions.
C program consists of one or more source program files.
C and C programs regard functions as an independent compilation unit.
D, a C program must have a main () function.
Automatic variable of 16. C language is ().
A, stored in the dynamic storage area.
B, stored in a static storage area.
C, stored in the register of computer CPU.
D. stored in an external memory.
17. The running result of the following program is ()
void swapl(x,y)
int x,y;
{ int t; t = x; x = y; y = t; }
void swap2(p 1,p2)
int *p 1,* p2
{ * p 1 = * p2; * p2 = * p 1; }
Master ()
{int a=3,b=5,* x 1 = & amp; a,* x2 = & ampb;
swap 1(a,b);
printf("a=%d,b=%dn ",a,b);
swap2(x 1,x2);
printf("a=%d,b=%dn ",a,b); }
A、
a=5,b=3
B,
a=3,b=5
C,
a=5,b=3
d、
a=3,b=5
a=5,b=3
a=3,b=5
a=3,b=3
a=5,b=5
18. In the following definitions, () is not defined by a pointer array.
a、int * p[5];
b、float * q[4];
c、int(* r)[6];
d、char * w[7];
19. The running result of the following program is ()
# Define sl(x)(3. 14*(x)*(x))
# Including
Master ()
{float x,s;
s = s 1( 10);
printf("%.2fn ",s); }
a、3. 14
b、3 1.40
c、3 14.00
d、6.28
20. The function name of the function that tests whether the file ends is ().
I. feof
b、EOF
c、eof
d、FEOF
Second, multiple-choice questions (this big question 10 small question, 2 points for each small question, a total of 20 points) Two to five of the five options listed in each small question meet the requirements of the topic. Please fill in the letter before the correct option in the brackets after the question. Multiple choices, fewer choices, and wrong choices all have no scores.
2 1. Which of the following devices are external storage devices ()
I. Ram
CD
C. hard disk
D, floppy disk
E. magnetic tape
22.? X* files. C can represent ()
a、AXCD。 C
b、AXCD。 D
ABX。 C
d、RX。 C
e、XX 1234。 C
23. if there is int x;; ; Floating y; Indicates the following expression () whose result is an integer.
a 、( int)(x+y)
b 、( int)x+y
c、a+x
d、x+(int)y
e、x*y
24. If the variables used have been correctly defined, the syntax in the following for loop statement is correct ().
a、for(x = 0; I = 0; I<= 10; i++)
x++;
b、for(x=0,i=0,i & lt= 10,i++)
x++;
c、for(x=0,I = 0; I<= 10; i++)
x++;
d、I = 0; x = 0;
For (I < =10; i++)
x++
e、I = 0; x = 0;
for(; I<= 10; i++)
x++
25. If there is a definition and assignment: ()
int y,*p,* p 1;
p = & ampy; p 1 = p; * p 1 = 4;
The statement that can output the address of the variable y is
a、printf("%un ",y);
b、printf("%un ",p);
c、printf("%un ",* p);
d、printf("%un ",& ampy);
e、printf("%un ",* p 1);
26. If there is a definition and assignment: ()
int a[ 10]={0, 1,2,3,4,5,6,7,8,9},* p;
p = a;
The expression that refers to the element with a value of 5 in is
a,a[5]
b、a[4]
c 、*(a+5)
d、p[5]
e 、*(p+4)
27. If there is a definition and assignment: ()
int a[6][6],* p;
p = * a;
Then the address expression in the following equation is
a、a[ 1]
b、a[ 1]+ 1
c、a[3][3]
d 、& amp[ 1][3]
e、p[0][0]
28. If there is a definition and assignment: ()
int x[5][6],* p;
p = * x;
The expression that cannot correctly reference the value of array element x[0][2] is
a、x[0][2]
b、p[0][2]
c、x[0]+2
d 、*x+2
e 、*(x+2)
29. The following are true ()
A, structure 1_num
{ long numstruct 1 _ num * next; }num 1,* p 1;
p 1 = & amp; num 1;
B, structural animals
{char name [30], float weight,} rabbit;
C, structure star
{int bh,char name [20],} my _ star
my _ star.name = " moon
d、struct { char x[20]; char y[30]; int u; }x 1,y;
E, structured food
{int code; char name[30]; Structured food * p;; };
Structured food * tail;
30. With int y, u=0, x= 15, the one that can make y value 0 is ().
a、y = x∧x;
b、y=x∣u;
c、y = x & gt& gt4;
y = x & ampu;
e、y = ~ u;
Part II Non-multiple choice questions
Three. Fill in the blanks (there are 10 small questions in this big question, and each small question is 1 point, with a total of1point).
3 1. Write the directory operation command C: > _ _ _ _ _ _ _ _ _.
32. The basic unit of C program is _ _ _ _ _ _ _.
33.33. The function of putchar () is _ _ _ _ _ _ _ _.
34. When s=7 and X = _ _ _ _ _ _ _ _ after executing the following program segment.
If ((s>0)&; & amp(s & lt= 10))
If ((s> = 3)&; & amp(s & lt= 6))x = 2;
else if((s & gt; 1)| |(s & gt; 8))x = 3;
else x = 1;
Otherwise x = 0;;
35. If I and X are both int types, then the maximum number of executions of the for loop statement is _ _ _ _ _ _ _ _.
for(i=0,x = 0; I<= 9 & amp& ampx; amp; x! =876; i++)scanf("%d ",& ampx);
36. The output of the following program is _ _ _ _ _ _ _.
Master ()
{int a[ 12]={ 1,2,3,4,5,6,7,8,9, 10, 1 1, 12},*p[4],I;
for(I = 0; I<4; i++)p[I]= & amp; a[I * 3];
printf("%dn ",p[3][2]); }
37. Variables can be defined inside or outside the function. The variables defined inside the function are called _ _ _ _ _ _ _ _ _.
38. If there is a definition of int x=3, * p;; Then let the assignment statement that P points to the variable X be _ _ _ _ _ _ _ _.
39. All members of a community share the same storage space, and the data type of each member can be _ _ _ _ _ _ _ _.
40. Settings file * fp;; Then the C statement to close the file contacted by fp is _ _ _ _ _ _ _ _ _.
4. Short answer questions (this big question has 4 small questions, 4 1 and 42 have 2 points for each small question, and 43 and 44 have 3 points for each small question, totaling 10).
4 1. Briefly describe the whole process of completing a C program in Turbo C 2.0 integrated development environment.
42. Write the mathematical formula corresponding to the following program segment.
If (x! =0)
if(x & gt; 0)y = 1;
else y =- 1;
Otherwise y = 0;;
43. Define char * string = "I am a boy";
And define char * string;;
String= "I am a boy";
Is it equivalent? Why?
44. Briefly describe the operating steps of C for ASCII code files or binary files.
V. Reading analysis questions (this topic is entitled 10, with 2 points for each question, totaling 20 points)
45. Read the following procedures and write down the operation results.
Master ()
{int a= 100,b =- 1;
printf("a=%d,%xn ",a,a);
printf("b=%x,%un ",b,b); }
46. The following is the procedure for judging whether a student has passed the exam (A, B or C is passed; Fail to get a d):
Master ()
{ char mark = " " A ";
Switch (tag)
{Case'' a'':
Case "b":
Case "c": printf ("> = 60n”);
Case "d": printf (<; 60n”);
Default value: printf ("errrn"); }}
What errors will occur after the program is executed? Please analyze and correct me.
Please refer to the procedures in Questions 47, 48 and 49 below and answer relevant questions.
Master ()
{int u,v,a,b,t,r;
u = 24v = 16;
if(u & gt; v){ t = u; u = v; v = t; }
a = u; b = v;
while((r=%ba)! =0)
{ b = a; a = r; }
printf("a=%dn ",a);
}
47. What is the output of the program?
48. What function does this program accomplish?
49. If you replace the while loop with the do-while loop, please write the corresponding program segment.
Please refer to the following procedures to answer questions 50, 5 1 and 52.
Long integer (integer)
{ if(n & gt; 0) returns n * fac (n-1);
Else returns1l;
}
Master ()
{int i,m;
Length s = 0;;
scanf("%d ",& ampm);
for(I = 1; I<= m;; i++)
s = s+fac(I); ;
printf("% 1dn ",s);
}
50. What is the function of this program? What is the function of fac?
5 1. Is it appropriate to define the return value of fac function as int?
52. If (1! )! +(2! )! +(3! )! +…+(m! )! How to modify the program?
For questions 53 and 54, please refer to the following procedures and answer relevant questions.
Structured food
{ int amount
struct food * next
} * head = NULL
void create(int each_amt)
{ struct food * p;
P= (structured food *)malloc(sizeof));
P→ amount = head _ amt
p→next = head;
head = p;
}
53. the statement p = (struct food *) malloc (the size of struct food);
And p → amount = each amount; But what is the function?
54. the statement p → next = head; head = p; What is the function of?
The programming problem of intransitive verbs (this big problem consists of two small questions, with 8 points for the 55th question and 20 points for the 56th question 12).
55. For any two-dimensional integer array with 3 rows and 3 columns, it is realized by programming:
(1) Specify initial values for array elements from the keyboard.
(2) Find the element with the largest element value in each column and output its value, row subscript and column subscript.
(Assuming that all elements in the array have different values)
56. Write a string copy function to copy the string pointed by pointer str2 to the string pointed by pointer str 1. Please call the string copy function in the main function and output the string pointed by str 1
(strcpy standard library function in C language is not allowed)
Computer Foundation and Programming Test Paper Reference Answer
1. Multiple-choice questions (there are 20 small questions in this big question, with each small question 1 point, totaling 20 points)
1.B
2.A
3.B
4.B
5.D
6.C
7.B
8.D
9.A
10.B
1 1.C
12.C
13.B
14.D
15.C
16.A
17.D
18.C
19.C
20.A
Second, multiple-choice questions (this big question has 10 small questions, each with 2 points, a total of 20 points)
2 1.BCDE
22. Automatic data entry
23. Automatic call distribution system
24. Church of England
25. Bachelor of Science
26. Automatic call distribution system
27. Associate Doctor
28. CDs
29. Automatic data entry
30. Automatic call distribution system
Three. Fill in the blanks (there are 10 small questions in this big question, and each small question is 1 point, with a total of1point).
3 1. Directory A:TC*. C
function
33. Output a character to the terminal.
34.3
35. 10 times
36. 12
37. Local variables
38.p = & ampx
39. Different
40.fclose(fp)
Fourth, short answer questions (this big question is 4 small questions, 4 1 and 42 questions are 2 points each; Questions 43 and 44 each have 3 points, totaling 10)
4 1. [Reference answer]
(1) Generate C source program with editing function.
(2) Using the compiler function to generate the corresponding target program.
(3) Using the connection function to generate the executable program.
(4) Run the executable program.
42. [Reference answer]
y =- 1(x & lt; 0)
y=0(x=0)
y = 1(x & gt; 0)
43. [Reference answer]
(1) equivalence. ( 1)
(2) Because string is a character pointer variable. ( 1)
(3) The two assignment methods only assign the first address of the string to the string, instead of assigning the whole string to the string. ( 1)
44 [Reference Answer]
(1) Opens the file in the specified format. ( 1)
(2) Read/write the opened file. ( 1)
(3) Close the open file. ( 1)
V. Reading analysis questions (this topic is entitled 10, with 2 points for each question, totaling 20 points)
45. [Reference answer]
A = 100,64 ( 1)
B=ffff,65535( 1)
46. [Reference answer]
(1) This program has a logical error. When marked as "a" (or "b" or "c"), all three printf statements should be executed once. ( 1)
(2) In order to get the correct result, the following modifications should be made: (1)
case ' ' C ':printf(" & gt; = 60n”); Break;
Case "d": printf (<; 60n”); Break;
47. [Reference answer]
A=8(2 points)
48. [Reference answer]
This program is used to find the greatest common divisor of u and v. (2 points)
49. [Reference answer]
The while statement can be changed to: (2 points)
r = b % a;
do
{
if(f = = 0)break;
b = a; a = r;
}while((r=b%a)! =0);
50. [Reference answer]
5 1. [Reference answer]
Not appropriate. An integer overflow will occur.
Even if it is defined as a long type, the input value of m cannot be too large, otherwise it will overflow. (2 points)
52. [Reference answer]
Just change s=s+fac(i) to:
S=s+fac(fac(i))。 (2 points)
53. [Reference answer]
(1) The previous sentence is used to create a new node, so that the pointer p points to the new node. ( 1)
(2) The last sentence is used to accept the independent variable of the calling program and assign its value to the membership of the new node. ( 1)
54. [Reference Answer]
(1) The last sentence is used to connect the new node with the node pointed by the original head. ( 1)
(2) The last sentence is used to make the head point to the newly added node P..( 1)
The programming problem of intransitive verbs (this big problem consists of two small questions, with 8 points for the 55th question and 20 points for the 56th question 12).
55. [Reference answer]
The reference procedure is as follows:
# Including
Invalid master (invalid)
{
int i,j,im,jm,x[3][3],max
for(I = 0; j & lt3; i++)
for(j = 0; j & lt3; j++)
scanf("%d ",& ampx[I][j]);
for(j = 0; j & lt3; j++)
{
max = x[0][j]; im = 0; JM = j;
for(I = 1; I<3; i++)
If (max {
max = x[I][j];
im = I;
JM = j;
}
printf("i=%d j=%d max=%dn ",I,j,max);
}
}
56. [Reference answer]
The reference procedure is as follows:
# Including
void strcpy(char *,char *);
Invalid master (invalid)
{
char *str 1,* str2 = " abcdef
strcpy(str 1,str 2);
printf("%s ",str 1);
}
void strcpy(char *s 1,char *s2)
{
int I = 0;
while((s 1[i]=s2[i])! ='''')
i++;
}