Computer Science, asked by daud2281, 7 months ago

Raju is the maths teacher in high secondary school and provided mark sheet to students.In this class room, students are arranged in the form of rows and columns. Raju needs to find the highest mark in each rows. Help him to find out.

Answers

Answered by jyosh357
16

Answer:

#include<iostream>

using namespace std;

int main()

{

 int r,c,i,j,max=0;

 std::cin>>r>>c;

 int a[r][c];

 for(i=0;i<r;i++)

 {

   for(j=0;j<c;j++)

   {

     std::cin>>a[i][j];

   }

 }

 max=a[0][0];

 for(i=0;i<r;i++)

 {

   max=a[i][0];

   for(j=0;j<c;j++)

   {

     if(max<=a[i][j])

       max=a[i][j];

   }

   std::cout<<max<<"\n";

 }

}

Explanation:

Answered by ArthamJayanth
7

Answer:

#include<iostream>

using namespace std;

int main()

{

   int r,c,i,j,max=0;

   std::cin>>r>>c;

   int a[r][c];

   for(i=0;i<r;i++)

   {

       for(j=0;j<c;j++)

       {

           std::cin>>a[i][j];

       }

   }

   max=a[0][0];

   for(i=0;i<r;i++)

   {

       for(j=0;j<c;j++)

       {

           if(max<=a[i][j])

           max=a[i][j];

       }

   }

   std::cout<<"The maximum element is "<<max<<"\n";

}

Explanation:

Using 2D arrays and checking for each element.

All test cases passed.

Similar questions