Write a C++ program that reads the record stored in marks.txt file and display the maximum marks
#include<iostream>
#include<fstream>
using namespace std;
int main(){
fstream file("marks.txt", ios::in);
string str;
int i=0;
while(file){
file>>str;
cout<<str<<" ";
i++;
}
string arr[i];
int max = arr[0];
int n=0;
while (file)
{
file>>arr[n];
cout<< arr[n]<<" ";
n++;
}
for(int k=0; k<i; i++){
if (arr[k]>max){
max = arr[k];
}
}
cout<<"Maximum max is: "<<max<<endl;
}
Comments
Leave a comment