Answer to Question #253773 in C++ for Bilal Tanveer

Question #253773

Write a C++ program that reads the record stored in marks.txt file and display the maximum marks


1
Expert's answer
2021-10-19T15:19:27-0400
#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;
    
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS