C++ Program to find maximum element from an array.
Jignesh Kothari
Posted on June 23, 2022
#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
💖 💪 🙅 🚩
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.