Hi,

I am new to C++, for my home work for intro to C++, well it would be easier if I just copy and paste the assignment.

*In this program, you will continuously track the minimum and maximum values of a file of integers as the file is read. Your program will: • read the integers, one by one, from a file. Code should work for a file of any length. • after reading each integer, it will call a function to determine if a new minimum value or new maximum value has been found • print the last integer read and the running minimum and maximum values. • format the output so that the numbers are right aligned.*

Do not use the library min/max functions for this program. Instead, write your own function with this prototype:

void minMax (int current, int& min, int& max);

All input and output should be done from your main program, not the function.

Your input file should be named “data.txt” and contain:

54 63 -30 48

12 254 832

-383

22 38 57 1020 19 30 183

-412 38

Your output should look exactly like this:

current is 54, min is 54, max is 54

current is 63, min is 54, max is 63

current is -30, min is -30, max is 63

current is 48, min is -30, max is 63

current is 12, min is -30, max is 63

current is 254, min is -30, max is 254

current is 832, min is -30, max is 832

current is -383, min is -383, max is 832

current is 22, min is -383, max is 832

current is 38, min is -383, max is 832

current is 57, min is -383, max is 832

current is 1020, min is -383, max is 1020

current is 19, min is -383, max is 1020

current is 30, min is -383, max is 1020

current is 183, min is -383, max is 1020

current is -412, min is -412, max is 1020

current is 38, min is -412, max is 1020

This is what I have so far..

```
#include<iostream>
#include<string>
#include<fstream>
using namespace std;
void minMax(int x, int y, int z,int& min, int& max);
int main()
{
float a;
int b;
int c;
int min,max;
ifstream out;
out.open("data.txt");
out>>a;
b=a;
c=a;
do
{
cout<<a<<" ";
minMax(a,b,c,min,max);
cout<<min<<" "<<max<<endl;
b=min;
c=max;
out>>a;
}while(out>>a);
system ("Pause");
}
void minMax(int x, int y, int z, int& min, int& max)
{
if(x<=y && x<=z)
{
min=x;
if(y<z)
max=z;
else
max=y;
}
else if (y<=z)
{
min=y;
if(x<z)
max=z;
else
max=x;
}
else
{
min=z;
if(x<y)
max=y;
else
max=x;
}
}
```

it works fine other than the fact that it skips over every other number in the data.txt file. Could anyone help me?

I still need to fix the output but been trying all day to get it to read the file right before I started working on output.