1、课程考试试题学期学年 2009-2010 1 C语言程序设计(C) 拟题人:校对人:拟题学院(系): 适 用 专 业: 信息科学与技术学院 信息08级,通信08级 (答案写在答题纸上,写在试题纸上无效).Choose the right answer (30 marks).1. Determine the output of the following statement:printf(%d, M - N);A) M - NB) M - NB) 3D) 12. Which of following is an illegal user-define symbol?A) scanf B) _12
2、3 C)C$ D)var3. 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;printf(%d %dn, +x, y+);A) 7,8 B) 9,7 C) 8,8 D) 8,96. Choose the wro
3、ng definition for the character strings. A) char str4= “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 main()int i, j, m = 0;for(i=1;i=15;i+=5)for(j=3;j 5)n-;printf(“%d”, n);A) 876 B) 765 C) 8765D) 765415. What is the fu
4、nctionality of function “rewind”?A) open the file again;B) return the length of the fileC) push the pointer to the end of the fileD) push the pointer to the beginning of the fileII. Short answer questions.(30 marks)1. a. Enumerate workflow control methods in C programming language. (5 marks)b. Give
5、a simple C program to show the basic parts of 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 n
6、ever give the correct result. (8 marks)#include void main()int num;printf(Enter a letter: );scanf(%d, num); num = num * num;printf(The result of num + num is %d, &num);b. Modify the program so it will display the proper result. (12 marks)III. Write the programs. (40 marks)1. Given an array a9, fill
7、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 an integer array,
8、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 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