Trending This Week:

test

Post Top Ad

Your Ad Spot

Wednesday, June 22, 2022

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

        





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 :



Hash Tags:

#CPP #Calculation #SumOfTwoNumbers #Plus #Programming #coding #Addition #Code #SourceCode #java #CLanguage #Python #Logical #Maths #pattern




No comments:

Post a Comment

Post Top Ad

Your Ad Spot