Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a complete C++ program (including comments in the main program and in the functions) to do the following: Write a function called readdata() which

image text in transcribed
Write a complete C++ program (including comments in the main program and in the functions) to do the following: Write a function called readdata() which will work with two variables, an integer n and a dimensional array vals, which contains up to 50 real numbers. The function will read a value for n, then read n real numbers. It will store the data values in the array vals. The function will print the original data values as they are read in. Write a function called countem() which will receive three parameters: an integer n, a value, and an array vals. The function will count how many of the first n elements of the vals array are larger than specval. Print each value that is larger than specval. Also, print (either in he main program or in the function) the number of values which are larger than specval. For example, if the array holds 66 10 - 7 0 4 31, with n = 6, and specval = 4, then 66 10 and 31 are larger than specval(). There are 3 values in the array which are larger. Write a function called multiplyall() which will multiply each element stored in the array 5. (The function receives the usual parameters--an array and an integer giving the size of the array.) For example, assume the array holds: 66 10 - 7 0 4 31, with n = 6, after the function call, the array holds 330 50 - 35 0 20 155. Write a function called findavg() which will find the average of the elements in an array (the usual parameters). The function will return the answer to the calling program. Write a function sortem() which receives two parameters, an array and n, the number of filled positions in the array. Sort the array in ascending numeric order. Write a main program which will call these functions. First the main program will call readdata() (see part 1) to read a set of data containing number elements into an array which the main program calls numbers. Then it will call the function countem() (see part 2) to find how many of the first number array elements are greater than 20. Then the main program will call multiplyall() (see part 3) to modify the numbers array. The new values in the array should be printed (either in the main program or in the function). Then the main program will call findavg() (see part 4) to find the average of the first number values in the numbers array. The main program should print the average. The main program will call the function countem() again, to determine how many items in the changed array are more than 50. The main program will call the function sortem() to sort the first n valuess in the numbers array. Upon return to main, print the sorted array. The main program will simply call the functions, making sure that all parameters have the appropriate type, etc. Assume that the array has no more than 100 real numbers. Make sure that each function receives the right parameters, with the right types, etc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

=+5. How does a synopsis differ from an executive summary? [LO-5]

Answered: 1 week ago