” 辅导SOF103实验编程、 写作Programming语言程序SOF103 C and C++ ProgrammingLab Exercise 4ArraysDue Date: 8 November 2020Late Submission Policy: Up to 4 hours late:10% penalty Up to 2 days late: 25% penalty More than 2 days late: 50% penalty No submission will be accepted after 4 days of the specified deadline: 100%penaltyPart A: Review QuestionsInstruction: Answer the following review questions1. Write C++ statement to accomplish each of the following:a) Display the 7th Element of array a.b) Input value into the 3rd element of array a.c) Calculate the sum of the first and second element of array a, then store it as the thirdelement.d) Print the element stored at the 3rd row, 2nd column of a 2D array table.e) Store the user input into the 5th element of array a.2. Write C++ statement to accomplish each of the following:a) Calculate the Sum of all (5) elements in array a.b) Initialize an integer array a with size of 10 as number from 1 to 10.c) Print the following character array in reverse order.d) Declare a Boolean array b with size of 5 and then read 5 integers from user. If thenumber is positive, store a true into it, otherwise store a false.Part B: Programming Practice1. One interesting application of computers is drawing graphs and bar charts (sometimescalled histograms). Write a program that reads five numbers (each between 1 and10). For each number read, your program should store the number in an integer array.Next, for every number in the array elements, print a line containing that number ofadjacent asterisks. For example, if your program reads: 2 3 5 8 4, it should print:Element Value Histogram0 2 **1 3 ***2 5 *****3 8 ********4 4 ****2. Given that array data is initialized as:int data[9] = {10, 11, 57, 22, 59, 33, 97, 26, 9};Write a program that read an integer and then search for the same number in the array, if thenumber is found, The program should output the index of the number, otherwise, the programshould tell user that the number is not in the array.Additional challenge: solve this problem without using any loopHint for challenge: 57 – 3 = 54, 22 – 4 = 18Example:3. Use single-subscripted array to solve this problem. Write a program that reads 10 charactersfrom user, then reverse the order of a part of the input. Try to use smallest possible size of extramemory to solve this problem.Example:4. Ten students were asked to rate the quality of the food in the student cafeteria on a scale of 1to 3 (1 means poor, 2 means average, 3 means good). Write a program to read the responsesof the 10 students into an array and summarize the frequency of the rating. An example isshown below.5. Use a single-subscripted Array to solve the following problem. Read in 10 numbers, each ofwhich is between 10 and 100, inclusive. As each number is read, print it only if it is not aduplicate of a number already read. Provide for the worst case in which all 10 numbers aredifferent. Use the smallest possible array to solve this problem.Enter the 10 responses: 1 3 2 3 2 1 3 2 1 2Rating Frequency1 32 43 36. Store the multiplication table for number from 1 to 12 as a 2 dimensional array then print it.Example:7. Table 1 is the summary of examination marks for three students. The students are labelled asstudent[0], student[1] and student[2]. The subjects are labelled as subject[0], subject[1],subject[2] and subject[3]. Use a two-dimensional array to store the students marks in the tableformat. Then, find the lowest mark, the highest mark and the average mark for student0,student1 and student2.subject[0] subject[1] subject[2] subject[3]student[0] 78 60 79 88student[1] 85 80 77 91student[2] 89 78 81 75Table 1: Student marks and subjectsAn example of the program output is:8. A company has three salespeople (labelled 1 to 3) who sell two different products (labelled 1and 2). Write a program to Enter the sales according to products by each salesperson. Then,summarize the total sales by printing a table that includes the total sales to the right and to thebottom of the table. As an example,Enter sales by salesperson 1 (product1 product2): 120 135Enter sales by Salesperson 2 (product1 product2): 230 100Enter sales by salesperson 3 (product1 product2): 250 150Product 1 Product 2 TotalSalesperson 1 $120.00 $135.00 $255.00Salesperson 2 $230.00 $100.00 $330.00Salesperson 3 $250.00 $150.00 $400.00Total $600.00 $385.00 $985.00subject[0] subject[1] subject[2] subject[3]student[0] 78 60 79 88student[1] 85 80 77 91student[2] 89 78 81 75Lowest mark: 60Highest mark: 91The average Mark for student 0 is 76.25The average mark for student 1 is 83.25The average mark for student 2 is 80.75如有需要,请加QQ:99515681 或邮箱:99515681@qq.com
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。