1、 课程考试试题 学期 学年 2009-2010 1 C语言程序设计(C) 拟题人: 校对人: 拟题学院(系): 适 用 专 业: 信息科学与技术学院 信息08级,通信08级
2、 (答案写在答题纸上,写在试题纸上无效) Ⅰ.Choose the right answer (30 marks). 1. Determine the output of the following statement: printf("%d", 'M' - 'N'); A) 'M' - 'N' B) M - N B) 3 D) 1 2. Which of following is an illegal user-define symbol? A) scanf B) _1
3、23 C)C$ D)var 3. Which statement is not a C statement? C) {int a; a++;} B) z = 20, a += c; C) ; D) { ; } 4. Which operator can only be applied to integers? A) %= B) / C) = D) <= 5. Determine the output of the following program. void main() { int y=8,x=7; print
4、f("%d %d\n", ++x, y++); } A) 7,8 B) 9,7 C) 8,8 D) 8,9 6. Choose the wrong definition for the character strings. A) char str[4]= “QUST”; B) char str[]= “QUST”; C) char *str= “QUST”; D) char str[]={‘Q’, ‘U’, ‘S’, ‘T’, ‘\0’}; 7. Determine the output of the following program. void m
5、ain() { int i, j, m = 0; for(i=1;i<=15;i+=5) for(j=3;j<=19;j+=3) m++; } printf("%d\n",m); A) 12 B) 15 C) 18 D) 25 8. For the 2-dimensional array int b[][3]={{1,0,-1},{10,12},{8,3,9},{0}}; the value for the b[2][1] is______. A) 8 B) 5 C)3 D) 12 9. In the statement
6、 while(x), choose the equivalent expression for the x. A)x==0 B)x==1 C)x!=1 D)x!=0 10. For the following codes: int z=5, *p=&z; the value of the *p is_______. A)the address of c B)unknown value C)the address of p D)5 11. In order to assign 45 to variant a and assign 64 to vari
7、ant b with the statement scanf(“%d%d”, &a, &b), which input format is correct? A) 45 64 B) 45, 64 C) 45;64 D) 4564 12. What is the byte length of the string “\t\\abcd”. A) 6 B) 7 C) 8 D) 9 13. Determine the output of the value of b. Int a[4][2] = {1,2,3,4,5,6,7,8}; b
8、 *(*(a + 2) + 1); A) 3 B) 4 C) 5 D) 6 14. Determine the output of the following program: main() { int n = 8; while (n > 5) { n--; printf(“%d”, n); } } A) 876 B) 765 C) 8765 D) 7654 15. What is the functionality of function “rewind”? A) open the file again; B)
9、 return the length of the file C) push the pointer to the end of the file D) push the pointer to the beginning of the file II. Short answer questions.(30 marks) 1. a. Enumerate workflow control methods in C programming language. (5 marks) b. Give a simple C program to show the basic parts of
10、 a C program.(5 marks) 2. a. The following program takes user input number and display the multiplication result of (num + num) in the next line on the screen, but it alway displays the wrong result. Determine where the errors are and why the program can never give the correct result. (8 marks)
11、include
12、y a[9], fill a with random values, then write a sorting method to sort the data in a and display the result.. (10 marks) 2. (a) Write a function named min( ) that accepts 5 integers as input , which calculates and returns the maximum value among them. The 5 integer numbers should be arrange into
13、 an integer array, and passed to the function min( ). (5 marks) (b) Include the function in a working program. Make sure your function is called from main() and correctly returns a value to main(). Display the value returned by min() in main(). (5 marks) 3. Write a program that declares a
14、 single-dimensional arrays named num,. The numbers to be stored in num are 45, 86, 12, 37, 28, 113. Sum odds and evens separately. Finally, give the results that will be displayed on the screen. (10 marks) 4. Given a function: Write a program to accept the user input for x, and display the value of y. 3






