南昌大学C程序设计双语作业与答案

上传人:人*** 文档编号:512033736 上传时间:2022-08-28 格式:DOC 页数:26 大小:96.50KB
返回 下载 相关 举报
南昌大学C程序设计双语作业与答案_第1页
第1页 / 共26页
南昌大学C程序设计双语作业与答案_第2页
第2页 / 共26页
南昌大学C程序设计双语作业与答案_第3页
第3页 / 共26页
南昌大学C程序设计双语作业与答案_第4页
第4页 / 共26页
南昌大学C程序设计双语作业与答案_第5页
第5页 / 共26页
点击查看更多>>
资源描述

《南昌大学C程序设计双语作业与答案》由会员分享,可在线阅读,更多相关《南昌大学C程序设计双语作业与答案(26页珍藏版)》请在金锄头文库上搜索。

1、Chapter 1 Introduction1、1. Which of the following are illegal identifiers?Circle the illegal identifiers. A.3id B._yes C.star*it D.int 教师批改:A C D 2、1. Which of the following are illegal identifiers?Circle the illegal identifiers. A. xyshouldI B. me_to-2 C. one_i_arent D. 2_i_am 教师批改:B C D Chapter 2

2、Learning by Example1、What is correct about the following program? #include #define count 6 void main(void) count = count + 1 ; printf(%d, count) ; A. 7 is output and count becomes 7 B 7 is output and count becomes 7 C. Runtime Error D. 7 is output but count remains 6 教师批改:C 2、Indicate which of the f

3、ollowing are legal variable names in C: A、X B、formula1 C、average_rainfall D、%correct 教师批改:ABC 3、Indicate which of the following are legal variable names in C: A、short B、tiny C、total rainfall D、aReasonablyLongVariableName 教师批改:BD 4、Indicate which of the following are legal variable names in C: A、12Mo

4、nthTotal B、marginal-cost C、b4hand D、_stk_depth 教师批改:CD 5、Indicate which of the following are legal variable names in C: A、short B、4formula C、average_rainfall D、%correct 教师批改:C 6、Indicate which of the following are legal variable names in C: A、short B、formula_5 C、average_rainfall D、4correct 教师批改:BC 7

5、、Indicate which of the following are legal variable names in C: A、short B、formula6 C.float D.printf 教师批改:BD 8、Consider the following code fragment:int dblarray10,*dblPointer;Which of the following statements are valid (i.e. which ones will compile)? Circle all the correct answers (there may be more

6、than one correct answer). A. dblPointer = dblArray; B. dblPointer = dblArray4; C. dblPointer = &(dblArray2); D. dblPointer = *dblArray; 教师批改:AC 9、Indicate the values and types of the following expressions:2+3 value:_type:_ 教师批改:5 integer 10、Indicate the values and types of the following expressions:

7、19/5 value:_ type:_ 教师批改:3 integer 11、Indicate the values and types of the following expressions:19.0/5 value:_type:_ 教师批改:3.8 double 12、Indicate the values and types of the following expressions:3*6.0 value:_type:_ 教师批改:18.0 double 13、Indicate the values and types of the following expressions:19%5

8、value:_type:_ 教师批改:4 integer 14、Indicate the values and types of the following expressions:2%7 value:_type:_ 教师批改:4 integer 15、By applying the appropriate precedence rules,calculate the result of the following expression:6+5/4-3,result is _ 教师批改:4 16、By applying the appropriate precedence rules,calc

9、ulate the result of the following expression:10+9*(8+7)%6)+5*4%3*2+1,result is _ 教师批改:42 17、By applying the appropriate precedence rules,calculate the result of the following expression:1+2+(3+4)*(5*6%7*8)-9)-10,result is _ 教师批改:42 18、Rewrite the following floating-point constants in Cs form for sci

10、entific notation:29979250000.0_ 教师批改:29979250000 19、Rewrite the following floating-point constants in Cs form for scientific notation:0.00000000529167_ 教师批改:0.00000000529 20、Evaluate the following expression: (2 Points)int i=1,j=2,k=3,m=4;i+=j+k; / i=_j*=k=m+5; / j=_ 教师批改:6 18 21、The variables are i

11、nitialized as follows,char c=A; int i=7,j=7;double x=0.0,y=2.3;Evaluate the following expressions: (5 Points)!c _!(i-j)_!i-j_!(x+y)_!x*!y_ 教师批改:0 1 -7 1 1 22、Indicate the values and types of the following expressions:2%7 value:_type:_ 教师批改:2 integer 23、By applying the appropriate precedence rules,ca

12、lculate the result of the following expression:2+2*(2*2-2)%2/2,result is _ 教师批改:2 24、The following C program is compiled and runs successfully. Write the output the following program produces. #include void main( ) int k = 42; printf(%dn, k+);_ printf(%dn, +k);_ return 0; 教师批改:42 44 25、Write a progr

13、am that reads in a list of integers until the user enters the value -1 as a sentinel.At that point,the program should display the average of the values entered so far. Chapter 3 Problem Solving1、 What is the output of the following code? #include void main(void) int a ; a = 1; printf(%i,+a) ; A. Com

14、pile-time Error B. 0 C.1 D. 2 教师批改:D2、Use #define to introduce a constant named pi with the value 3.14159_ 教师批改:#define pi 3.14159 3、Write a printf statement to display the floating-point value stored in the variable distance so that exactly three digits appear to the right of the decimal point_ 教师批改:printf(%.3f,distance); 4、Use for control line

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 教学/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号