Monday 22 April 2013

Getting Maximum Value from Array Elements

Description:

This program take different values from user and store these values in array and find maximum value from these entered values automatically.

Code:


#include<iostream>
#include<conio.h>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
    int i,j,k,a[5],max;
    cout<<"enter values of elements of array"<<endl;
    for(i=0;i<=4;i++)
    {cout<<"a["<<i<<"]=";
    cin>>a[i];
    cout<<endl;}
    cout<<"your entered elements of array are"<<endl;
    for(i=0;i<=4;i++)
    {cout<<a[i];
    cout<<endl;}
    max=a[0];
    for(i=0;i<=4;i++)
    {
    if(max<a[i])
    max=a[i];}
    cout<<"maximum valu is "<<endl<<max;
    getche();
    return 0;
 
    }


Output:


No comments:

Post a Comment