ImageVerifierCode 换一换
格式:DOCX , 页数:16 ,大小:18.39KB ,
资源ID:9608792      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9608792.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(用C++解决问题第十版Chapter 7.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

用C++解决问题第十版Chapter 7.docx

1、用C+解决问题第十版Chapter 7TRUE/FALSE1.The indexed variables (members) of an array must be integers.ANSWER: FALSE2.The locations of the various indexed variables in an array can be spread out all over the memory.ANSWER: FALSE3.The following array declaration is legaldouble scores=0.1,0.2,0.3;ANSWER: true4.A

2、rrays can be passed to functions.ANSWER: TRUE5.Arrays can be returned from a function.ANSWER: FALSE6.If a function is expecting a pass by reference parameter, you can pass an index variable from an array of the same base type to that function.ANSWER: TRUE7.When you have a function that expects an ar

3、ray, it should also expect the size of the array or the number of indexed variables with valid data.ANSWER: TRUE8.The following function declaration guarantees the values in the array argument are not changed.void function1(int array, int numElements);ANSWER: FALSE9.The following function will work

4、with any size integer array.void function1(int array, int numElements);ANSWER: TRUE10.If you use the const modifier in a function declaration, you do not include it in the function definition.ANSWER: FALSEShort Answer1.Write the code to declare a two dimension array of integers with 10 rows and 20 c

5、olumns.ANSWER: int array1020;2.Write the code to declare an array of 10 doubles named list;ANSWER: double list10;3.The modifier that guarantees that an array argument will not be changed is called _.ANSWER: const4.How many indexed variables does the following array have?int myArray=1,2,3,6,5,4,7,1,2

6、;ANSWER: 95.How many indexed variables does the following array have?int myArray12=1,2,3,6,5,4,7,1,2;ANSWER: 126.Write the declaration for a function named funct1 that expects an array of floats, the number of elements in the array and does not return any value.ANSWER: void funct1(float myArray, int

7、 numElements);7.If you put a value in the square brackets of a one-dimension array parameter, this value is _ by the compiler.ANSWER: ignored8.If your index used to access the indexed variables of the array has the value of a non-existent index, this is called _ANSWER: Index out of range, Index out

8、of bounds, or illegal.9.The computer remembers the address of which indexed variable(s) in an array? _ANSWER: the first10.A computers memory consists of numbered locations called _.ANSWER: bytes11.In the expression double score10;double is called the _ of the arrayANSWER: base type12.In the expressi

9、on cout scorei endl;i is called theANSWER: index or subscript13.An _ is used to process a collection of data all of which is the same type ANSWER: array14.The individual variables that comprise an array are called _ANSWER: indexed variables, subscripted variables, or elements.15.Indexes are numbered

10、 starting at _ANSWER: 0Multiple Choice1.What are the valid indexes for the array shown below?int myArray25;a.0-25b.0-24c.1-25d.1-24ANSWER: B2.What is wrong with the following code?float scores10, total;a.Cannot declare regular and array variables together.b.Arrays must be integersc.The 10 should be

11、replaced with a variable name, whose value is input from the userd.Nothing.ANSWER: D3.Given an array named scores with 25 elements, what is the correct way to access the 25th element?a.scores+25b.scores24c.scores25d.scoreslastANSWER: B4.Why should you use a named constant for the size of an array?a.

12、Readability of codeb.Makes changes to the program easierc.Helps reduce logic errorsd.All of the aboveANSWER: D5.Given an array of integers of size 5, how does the computer know where the 3rd indexed variable is located?a.It adds 3 to the base address of the arrayb.It adds space for 3 integers to the

13、 base address of the arrayc.It remembers where all the indexed variables of the array are located.d.None of the aboveANSWER: B6.What is wrong with the following code fragment?const int SIZE =5;float scoresSIZE;for(int i=0; i=SIZE;i+) cout scoresi;a.Array indexes start at 1 not 0b.Arrays must be inte

14、gersc.Array indexes must be less than the size of the arrayd.Should be cin scores0;ANSWER: C7.Which of the following declare an array of 5 characters, and initializes them to some known values?a.char array5=a,b,c,d,e;b.char array4=a,b,c,d,e;c.char array5=;d.char array=a,b,d,e;e.A and Cf.B and Dg.all

15、 of the aboveANSWER: E8.If you declare and initialize an integer array of size 10, but only list 5 values, what values are stored in the remaining 5 indexed variables?a.0b.garbagec.0.0d.0ANSWER: A9.Arrays are always passed to a function usinga.pass by valueb.pass by referencec.pass by arrayd.you can

16、not pass arrays to a functionANSWER: C10.Give the following declarations, which of the following is a legal call to this function?int myFunction(int myValue);int myArray1000;a.cout myFunction(myArray);b.cout myFunction(myArray0);c.myArray = myFunction(myArray);d.myArray1 = myFunction(myArray0);e.A a

17、nd Bf.A and Cg.B and DANSWER: G11.Which of the following function declarations correctly expect an array as the first argument?a.void f1(int array, int size);b.void f1(int& array, int size);c.void f1(int array100, int size);d.void f1(float array, int size);e.All of the abovef.C and Dg.A and BANSWER:

18、 F12.Which of the following function declarations correctly guarantee that the function will not change any values in the array argument?a.void f1(int array, int size) const;b.void f1(int array, int size);c.void f1(int &array, int size);d.void f1(const int array, int size);e.void f1(int array, const

19、 int size);ANSWER: D13.The following function definition has an error in it. What line is this error on?0. void f1(const double array, int size)1. 2. int i=0;3. while(i size)4. 5. arrayi += 2;6. cout arrayi;7. i+;8. 9. a.0b.2c.5d.6e.2ANSWER: C14.Which of the following function declarations could be

20、used to input data from the keyboard into the array? a.void input(int array, int &numElements, int MAX_SIZE);b.void input(int array, int numElements, int MAX_SIZE);c.void input(int &array, int numElements, int MAX_SIZE);d.int array input(int array, int &numElements, int MAX_SIZE);ANSWER: A15.If we w

21、ant a search function to search an array for some value and return either the index where the value was found, or -1 if not found, which of the following prototypes would be appropriate?a.void search(const int array, int target, int numElements);b.void search(const int array, int target);c.int searc

22、h(const int array, int numElements);d.int search(const int array, int target, int numElements);ANSWER: D16.Given the following function definition for a search function, and the following variable declarations, which of the following are appropriate function invocations?const int SIZE=1000;int searc

23、h(const int array, int target, int numElements);int arraySIZE, target, numberOfElements;a.search(array0, target, numberOfElements);b.result=search(array0, target, numberOfElements);c.result=search(array, target, numberOfElements);d.result=search(array, target, SIZE);ANSWER: C17.Given the following f

24、unction definition, will repeated calls to the search function for the same target find all occurrences of that target in the array?int search(const int array, int target, int numElements) int index=0; bool found=false; while(!found) & (index numElements) if(arrayindex = target) found=true; else ind

25、ex+; if(found=true) return index; else return -1;a.Yesb.No c.Impossible to tell without looking at the values of the arrayd.It depends on the value of target.ANSWER: B18.Given the following function definition, what modifications need to be made to the search function so that it finds all occurrence

26、s of target in the array?int search(const int array, int target, int numElements) int index=0; bool found=false; while(!found) & (index size;int arraysize;c.int array=0,0,0;d.const int size=9;int arraysize;e.All of the abovef.All but Cg.All but BANSWER: G21.Which of the following function declaratio

27、ns will accept the following two-dimension array?int pages1030;a.void f1(int pages, int size);b.void f1(int pages30, int size);c.void f1(int pages10, int size);d.void f1(int& pages, int size);ANSWER: B22.If you need a function that will handle multi-dimensional arrays, you must specify the following

28、 sizes inside the square brackets.a.All the sizesb.All sizes except the last dimensionc.All sizes except the first dimensiond.None of the sizesANSWER: C23.What is the output of the following code fragment? int array44, index1, index2; for(index1=0;index14;index1+) for(index2=0;index24;index2+) arrayindex1index2=index1 + index2; for(index1=0;index14;index1+) for(inde

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1