The following
#include <iostream>
using namespace std;
// Write your function prototype here
int main()
{
const int SIZE = 10:
int userNums[SIZE];
cout ≪ “Enter 10 numbers: ”;
for (int count = 0; count < SIZE; count++)
{
cout ≪ “#” ≪ (count + 1) ≪ “ ”;
cin ≫ userNums [count];
cout ≪ “The average of those numbers is ”;
cout ≪ avgArray(userNums. SIZE) ≪ endl;
return 0;
}
//
// Write the function avgArray here.
//
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
STARTING OUT WITH C++: >CI<
Additional Engineering Textbook Solutions
Database Concepts (8th Edition)
Starting Out with Python (4th Edition)
Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Modern Database Management (12th Edition)
- C++ Write the function with function header double searchId( int idl[], double scorel[], int id, int size) that recieves as arguments the arrays idl (array containing student's IDs) and scorel (array containing their test scores), a student's ID, and the size of the arrays. The arrays are such that the score of the student with ID idl[j] is score [j]. This function searches the array idl for the ID recived, and if it is found, it returns the corresponding test score; otherwise it returns -1. write the function main that does the following: 1.Define the arrays idlist to hold the IDs of 20 students (integer values), and scorelist to hold their test scores (double precision values) 2.Read the 20 student's IDs and their test scores from the standard input into the arrays idlist and scorelist respectively. Each input line will have an ID and a corresponding score. 3.Read the ID of a student and look for their test score (by calling function searchId(). 4.If the ID is found in the list (the…arrow_forwardWrite a function that gets an array as a parameter (address and size) and a number and checks to see if that number exists in the array. The function should report every single occurrence of the number in the array. It should also report how many occurrences were detected in total (use c code)Suggested prototype: void findnReport(int* ar, int size, int num) Example of function output: If array = {2,5,3,5,12,13,14,15,0,5,-1,11,5} and num = 5, Number 5 found in array index 1 Number 5 found in array index 3 Number 5 found in array index 9 Number 5 found in array index 12 Total of 4 occurrences of number 5arrow_forwardIn this assignment, rewrite the Bubble Sort, Selection Sort and Insertion Sort functions meeting the following requirements: Each function must be implemented using recursion Each function sorts a given array of numbers in descending order Your main program should be calling these functions with an unsorted array of numbers and then printing the results of the sorted array on the screen. You may test these functions using any data you deem appropriate. One example is to code main as follows: public static void main(String[] args) { int testArray1[] = {… (use your own test data) …}; int testArray2[] = {… (use your own test data) …}; int testArray3[] = {… (use your own test data) …}; recursiveBubbleSort(testArray1, …); printArray(testArray1); recursiveSelectionSort(testArray2, …); printArray(testArray2); recursiveInsertionSort(testArray3, …); printArray(testArray3); } “printArray” in this example…arrow_forward
- 6. Write a function that accepts an array of integers and returns -1 if sorted in ascending order, 1 if sorted in descending order, and 0 if not sorted. To be as efficient as possible, your function should make only one pass through the array.arrow_forwardIn C++ please Write a program to simulate a pick-5 lottery game. Your program should generate and store 5 distinct numbers between 1 and 9 (inclusive) into an array. The program prompts the user to enter five distinct between 1 and 9 and stores the number into another array. The program then compares and determines whether the two arrays are identical. If the two arrays are identical, then the user wins the game; otherwise the program outputs the number of matching digits and their position in the array. Your program must contain a function that randomly generates the pick-5 lottery numbers. Also, in your program, include the function sequential search to determine if a lottery number generated has already been generated.arrow_forwardC++ Write a function SwapArrayEnds() that swaps the first and last elements of the function's array parameter. Ex: sortArray = {10, 20, 30, 40} becomes {40, 20, 30, 10}. Use this code: #include <iostream>using namespace std; /* Your solution goes here */ int main() { const int SORT_ARR_SIZE = 4; int sortArray[SORT_ARR_SIZE]; int i; int userNum; for (i = 0; i < SORT_ARR_SIZE; ++i) { cin >> userNum; sortArray[i] = userNum; } SwapArrayEnds(sortArray, SORT_ARR_SIZE); for (i = 0; i < SORT_ARR_SIZE; ++i) { cout << sortArray[i] << " "; } cout << endl; return 0;}arrow_forward
- 1. single element of an array can be passed to the function? true or false. 2. Array can be declared as constant? true or false. 3. which of the following gives the memory address of the first element in array x? a. X b. X[0] c. X{0} d. X_0 e. X(0) 4. The index of the last element of array X whose size is S? a. S+1 b. S-1 c. 0 d.1000 e. S 5. Assume you have the following declarations const int MAX = 1000;double A[MAX];which of the following sentences is incorrect? a. The assingnment statement MAX = 1000 is mandatory. b. we can store up to 1000 values in the mandatory. c we cannot change the size of the array A during the runtime. d. all values in the array are set to ZERO's (0) e. all above sentences are correct. 6. The only difference between char array and string is that, the string ends with '\0'? true or false. 7. Index of an array can be of type integer or double, since both deals with the digits? True or False 8. Which definition describes the term Array precisely?…arrow_forwardWrite a function named(Count_elements), that accepts a one-dimensional array and its size, returns how many elements of the array divisible by 3 and by 2. e.g. the array is [1,7,13,22,15,6,4,3,2,9,21] the output is:2arrow_forwardIn C++ please ! Write a Program that: Initializes an interger array size of 10 with random intergers in range [10,30]. Use a function named 'initialized_array' to acheive that. Determine if all array elements are distinct from each other or not.Use boolean function named 'distinct_elements' to achieve that function 'distinct elements, if the elements in the array are duplicate print out, elements are duplicate if not print out arrayarrow_forward
- Write a function that accepts an int array and the array’s size as arguments. The function should create a new array that is two elements larger than the argument array. The first two elements of the new array should be set to 0. Element 0 of the argument array should be copied to element 2 of the array, element 1 of the argument array should be copied to element 3 of the new array, and so forth. The function should return a pointer to the new array. Demonstrate the function in a complete program.arrow_forward1 ) Write a function that accepts an int array and the array’s size as arguments. The function should create a copy of the array, except that the element values should be reversed in the copy. The function should return a pointer to the new array. Demonstrate the function in a complete program. 2) use #include <iostream>arrow_forwarduse C++ programming language Write a modular program that analyzes a year’s worth of rainfall data. In addition to main, the program should have a getData function that accepts the total rainfall for each of 12 months from the user and stores it in an array holding double numbers. It should also have four value-returning functions that compute and return to main the totalRainfall, averageRainfall, driestMonth, and wettestMonth. These last two functions return the number of the month with the lowest and highest rainfall amounts, not the amount of rain that fell those months. Notice that this month number can be used to obtain the amount of rain that fell those months. This information should be used either by main or by a displayReport function called by main to print a summary rainfall report similar to the following: 2019 Rain Report for Springdale County Total rainfall: 23.19 inches Average monthly rainfall: 1.93 inches The least rain fell in January with 0.24 inches. The most rain…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr