C++ Program to find maximum element from an array.

jigneshkothari

Jignesh Kothari

Posted on June 23, 2022

C++ Program to find maximum element from an array.

#include <iostream>
using namespace std;
int main() {
int n,i,max;
cout<<"Enter Size of Array : ";
cin>>n;
int arr[n];
for(i=0;i<n;i++)
{
cin>>arr[i];
}
max=arr[0];
for(i=0;i<n;i++)
{
if(arr[i]>max)
max=arr[i];
}
cout<<"Max Element is : "<<max;
return 0;
}

Output:

Enter Size of Array : 5
65
78
23
90
89
Max Element is : 90

💖 💪 🙅 🚩
jigneshkothari
Jignesh Kothari

Posted on June 23, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related