Hi. My question is how do i find the highest and lowest entered price? I have to get the result in '.txt' file. I already get all the prices writen there but how do i make it write the highet and lowest prices entered into the '.txt' file? does it require loop in loop?
#include<iostream>
#include<fstream>>
usingnamespace std;
int main(){
float x;
ofstream fr("results.txt");
cout<<"Price of first product?"<<endl;
cin>>x;
fr<<"all the prices:"<<x<<endl;
while(x!=0){
cout<<"enter the price of another product or 0 to quit"<<endl;
cin>>x;
fr<<x<<endl;
}
fr.close();
return 0;
The traditional way to do this is to enter the prices into an array, then scan the array for highest and lowest. That can be done with two separate loops. One to enter the values, then one to scan for high and low values.