I need help with this program im working on where you get input from a file and the program checks if the numbers are in ascending order or not and which one is the smallest and largest number in the series..cant use arrays..
This is a my input.txt right now
1
2
3
4
5
and here is my code so far
#include <fstream>
#include <iostream>
int main( )
{
using namespace std;
ifstream in_stream;
ofstream out_stream;
in_stream.open("input.txt");
if( in_stream.fail() ){
cout << "The input file does not exist";
}
out_stream.open("output.txt");
int input, min_store, max_store,store;
char ans;
in_stream >> input;
min_store = input;
max_store = input;
for ( int i = 0; i < 5; i++){
in_stream >> store;
if( store < input ){
ans = 'n';
}
if( input > max_store ){
max_store = input;
}
if( store < min_store ){
min_store = store;
}
in_stream >> input;
}
if ( ans = 'n' ){
out_stream << "The numbers are not in ascending order"<< endl;
}
else{
out_stream << "The numbers are in ascending order"<< endl;
}
out_stream << "The smallest number is "<< min_store<< endl;
out_stream << "The largest number is "<< max_store<< endl;
in_stream.close( );
out_stream.close( );
return 0;
}