Sunday, March 17, 2013

Maximum Of An Array

#include<iostream>
using namespace std;
int main()
{
    int arr[10];
    for(int i=0;i<10;++i)//taking input
    {
        cout<<"Enter num"<<i+1<<": ";
        cin>>arr[i];
    }
    int max=arr[0];
    for(int i=0;i<10;++i)//finding the maximum
    {
        if(max<arr[i])
        max=arr[i];
    }
    cout<<"\n\nThe max. of given array is "<<max;
    return 0;
}

0 comments:

Post a Comment