HELP HELP

hello i new to all this
im looking for some help i hope u guys can help me
using namespace std;
double min,sub, max;
const int SIZE =10;
int list[SIZE];
int numbers;
char infile[10];
ifstream in_stream;
cout<<"enter input file name:"<<endl;
cin>>infile;
in_stream.open(infile);
if (in_stream.fail())
{
cout<<"Input file opening failed.\n";
cout <<"Enter input file name.\n";
cin>>infile;
in_stream.open(infile);
}
in_stream>>numbers;
while (!in_stream.eof())
{
in_stream>>numbers;
for (numbers=1;numbers<SIZE; numbers++)
{
cin>>list[numbers];

}
}
cout<<"Enter minimum value:"<<endl;
cin>>min;
cout<<"Enter maximum value:"<<endl;
cin>>max;
if (min>=max )
cout<<"Enter minimum value lower than maximum value ."<<endl;
cin>> min ;
if (max<=min )
cout<<"Enter maximum value greater than minimum value."<<endl;
cin>> max;

cout <<"Values between "<<min<<" and "<< max<<" are :"<<endl;
RIGHT HERE I NEED A CODE THAT WOULD GO Through THE NUMBERS OF THE FILE
AND GET A RANGE FROM MIN TO MAX OUT OF THE ARRAY
HERE I'D POLITELY REQUEST YOU TO... ugh... I'm so not doing this

Seriously macsuma, it's a PITA to write in ALL CAPS, but anyways:

1. what are you trying to do here?
1
2
3
4
5
6
7
8
9
10
while (!in_stream.eof())
{
    in_stream>>numbers; // what are the contents of your input file?
    for (numbers=1;numbers<SIZE; numbers++)
    {
           // are you really asking for another input of numbers here?
           // or perhaps you want to put the numbers read from your file into the array?
           cin>>list[numbers]; 
    }
}


2.
1
2
3
4
5
cout <<"Values between "<<min<<" and "<< max<<" are :"<<endl;
/* here you'd probably want to iterate through the array of numbers,
*  do a comparison to min and max
*  and outputs those that are within the range
*/ 


3. use code tags...
Last edited on
hoe can i do the second step
im sorry guy im really new at this
i appreciated all the help i can get
thank u

macsuma wrote:
hoe can i do the second step
1
2
3
4
/* here you'd probably want to iterate through the array of numbers,
*  do a comparison to min and max
*  and outputs those that are within the range
*/ 

um, pseudo code:

for each number n in the array: 
    compare n to min and max
         if n is less than min, discard n
         if n is more than max, discard n
         else print n
next n
Topic archived. No new replies allowed.