资源预览内容
第1页 / 共26页
第2页 / 共26页
第3页 / 共26页
第4页 / 共26页
第5页 / 共26页
第6页 / 共26页
第7页 / 共26页
第8页 / 共26页
第9页 / 共26页
第10页 / 共26页
亲,该文档总共26页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
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 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 following 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、12MonthTotal 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、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 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: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 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,calculate 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 scientific 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 initialized 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,calculate 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 program 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. Compile-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
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号