Computer Science, asked by simranchugh9085, 7 months ago

Highest mark in the class The teacher who handles science for 3rd-standard class distributes the mark sheets to her students, she needs to find the highest mark among the "n" students. Help the teacher to find the maximum mark. Input Format: The first input contains an integer 'n' which denotes the number of students The remaining input denotes mark of 'n' students separated by spaces Output Format: Print the highest mark Sample Input: 5 45 67 89 34 22 Sample Output: 89

Answers

Answered by jsrijareddy92
4

#include<iostream>

int main()

{

int n,i,value,j;

std::cin>>n;

 int a[n];

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

 {

   std::cin>>a[i];

 }

     value=a[0];

   

 for(i=1;i<n;i++)

 {

   if(a[i]>value)

   

     value=a[i];

   

}

std::cout<<value;

 return 0;

}

Answered by pranalipatil3620
9

Answer:

#include<iostream>

using namespace std;

int main()

{

 int n,max;

 cin>>n;

 int arr[n];

 for(int i=0;i<n;i++)

 {

   cin>>arr[i];

 }

 max=arr[0];

 for(int i=0;i<n;i++)

 {

   if(arr[i]>max)

     max=arr[i];

 }

  cout<<max;

}

Explanation:

Similar questions