InterviewSolution
Saved Bookmarks
| 1. |
Use the following array of 8 integers to answer the following questions, {2,3,2,1,2,5,8,2} a) You are required to write a user defined C++ function that will receive the above array as a parameter, and will loop through it and re-arrange it into the following final output {5,3,1,8,2,2,2,2} and display it from the main function of your program. The idea is to position all values equal to 2 in the array to come after the other values not equal to 2. The order of the other values i.e 5,1,3 and 8 does not matter as long as they appear positioned before all 2s as illustrated in the hint below: Initial array: {2,3,2,1,2,5,8,2} NumbertoMove = 2 Final Array: {5,3,1,8,2,2,2,2} b) Write another separate function in the same program above that takes the array above, {2,3,2,1,2,5,8,2} and loops through the elements calculating the sum and product of all the elements and displays them. |
| Answer» ALLAHABAD MAHAKUMBH of TTTT of tttt the FIELD the POSITION of tttt of | |