MAXIMUM OF N NUMBERS - CPPIOU006

Description:

Write a program to find the maximum of N numbers. Input :- First line contains "n" number of integer and the second line contains n integers Output :- maximum of entered elements Test Case 1 Input (stdin) 3 2 4 7 Expected Output 7 Test Case 2 Input (stdin) 4 -7 -9 -3 0 Expected Output 0

Program :

#include <iostream>

using namespace std;

int main()

{

    int n,i;

  float arr[10];

  cin>>n;

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

  {

    cin>>arr[i];

  }

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

  {

    if(arr[0] < arr[i])

      arr[0] = arr[i];

  }

  cout<<arr[0];

return 0;

}