The following
// Write the avgArray function prototype here.
// It should have a const array parameter.
int main()
{
const int SIZE= 10;
int userNums[SIZE];
cout << "Enter 10 integers: ";
for ( int count= O; 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 avgArray function here.
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
Digital Fundamentals (11th Edition)
Concepts of Programming Languages (11th Edition)
Concepts Of Programming Languages
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- use 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_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_forward// New Function prototypes void showValues(const int *, int); // display 10 numbers in a line from the array void fillArray(int *, int, int, int); // fill out random numbers between low and high into the array bool searchValue(const int *, int, int); // search value from the array void sortArray( int *, int); //sort the array in an ascending order void swap(int *, int *); //swap the values Modify the code below to create 50 random numbers instead of 10 and use the above new function protoypes. In the output, remove the display of the minimum, maximum and average from the array. Modify the showValues() function to display 10 numbers in a line from the array. [Part 2] Add the two functions to sort an array in an ascending order: void sortArray(int*, int); //ascending ordervoid swap(int*, int*); In the sortArray() function called the swap() function to swap the values from two elements in the array. Code: #include <iostream>#include <iomanip>#include…arrow_forward
- Write a function that finds the smallest element in an array of double valuesusing the following header:double min(double array[], int size);Write a test program that prompts the user to enter 5 numbers, invokes this function, and displaysthe minimum value (use the following values: 17.2, 7.9, 11.56, 4.3, 5.7).arrow_forwardUse C++ programing 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 inchesarrow_forwardWrite a function string_length() that calculates the length of the input character array. The array will be NULL terminated. i.e. the last element of the array will be '\0'. This null character will not be included in the array length. The function should return the length as an integer value. Use of built-in functions for finding string length is NOT allowed. The function has the following prototype: int string_length(char array[]); Task 3: Count the number of times a given number appears in an array Write a function count_num_times() that searches for a given number in the input array. The function should return the number of times the searched number appears in the array. The prototype for the function is given below: int count_num_times(int array[], int size, int num);arrow_forward
- (C language) Write a function intersect() that takes five arguments: an array of integers, number of elements in this array, a second array of integers, number of elements in the second array, a third array as parameters; finds the numbers in the first array that also exist in the second array and places these numbers into the third array; returns the number of matching values stored in array-3. Prototype: int intersect(int ar1[], int n1, int ar2[], int n2, int ar3[]) ps: please do not copy paste from chegg or anywhere else. write a unique code.arrow_forward// Reverse.cpp - This program reverses numbers stored in an array.// Input: None// Output: Original contents of array and the reversed contents of the array. #include <iostream>#include <string>using namespace std;void reverseArray(int[]);int main() { int numbers[] = {100, 90, 80, 70, 60}; int x; // Print contents of array // Call reverseArray() function here // Print contents of reversed array return 0;} // End of main() function// Write reverseArray function here.arrow_forwardWrite the following function that tests whether the array has four consecutive numbers with the same value. bool isConsecutiveFour(const int values[], int size) Write a test program that prompts the user to enter a series of integers and displays if the series contains four consecutive numbers with the same value. Your program should first prompt the user to enter the input size—i.e., the number of values in the series. Assume the maximum number of values is 80. Here are sample runs: Enter the number of values: 8 Enter the values: 3 4 5 5 5 5 4 5 The list has consecutive fours Enter the number of values: 9 Enter the values: 3 4 5 5 6 5 5 4 5 The list has no consecutive foursarrow_forward
- 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_forwardC++ The program asks for the number n. Next, we enter n numbers and store all entered numbers into an array. You need to input only two "zero" numbers. The program should display the sum of all numbers that are located between zeros. Input: 10 6 19 0 -3 4 8 0-6 9 5 Output: 9 Note: Numbers between two zeros are -3, 4 and 8. And their sum equal to -3+4+8=12 Greate a function for this task in this way: int sum_between_zeros(int a[], int size){}arrow_forwardC++The program asks for the number n. Next, we enter n numbers and store all entered numbers into an array. You need to input only two "zero" numbers.The program should display the sum of all numbers that are located between zeros.Input:106 19 0 -3 4 8 0-6 9 5Output: 9Note: Numbers between two zeros are -3, 4 and 8. And their sum equal to -3+4+8=12Greate a function for this task in this way:int sum_between_zeros(int a[], int size){}arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr