Question: . Complete the program minmax.cpp which uses two functions readdata ( ) and minmax ( ) to find the minimum and maximum of a set

. Complete the program minmax.cpp which uses two functions readdata() and minmax() to
find the minimum and maximum of a set of floats stored in the file minmaxin.txt.
- The main program opens the input and output files, and allocates a float array x, then calls
the functions readdata() and minmax() and finally prints the minimum and maximum values
to the output file minmaxout.txt.
- The input file minmaxin.txt includes a single column of data, where the first number (an
int) indicates the number of floats which follow. You can assume that the file holds no more
than 100 values.
- The function readdata() reads the first number, n, from the input file and then reads the
following n floats into the array.
- The function minmax() computes the minimum and maximum values found in the array.
Here is the expected program output:
The a r r a y has 80 el em e n t s
The maximum v al u e i n the a r r a y i s 63.606
The minimum v al u e i n the a r r a y i s 4.8089
/* F i l e : minmax . cpp
Programmer : Date :
*/
// i n c l u d e l i b r a r i e s
using namespace s t d ;
const int MXN =100; // maximum arr a y s i z e
// f u n c t i o n p r o t o t y p e s
int main ( void)
{
// open i n p u t and o u t p u t f i l e s
// d e c l a r e v a r i a b l e s and a l l o c a t e arr a y x
// c a l l re a d d a t a () t o read v a l u e s from t h e i n p u t f i l e t o t h e arr a y
// c a l l minmax () t o compute t h e minimum and maximum v a l u e s
// p r i n t t h e r e s u l t s t o t h e o u t p u t f i l e
// c l o s e f i l e s
return 0 ;
}
// f u n c t i o n d e f i n i t i o n s
4. Modify the previous program so that the array is dynamically allocated within the function
void readdata(). Call your new program minmaxd.cpp with output file minmaxdout.txt.
The output of the program will not change

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!