Write a program in c++ to input 5 number and find the largest

   

Write a program in c++ to input 5 number and find the largest


#include <iostream>
using namespace std;
int main()
{
    int i;
    float a[5], sum = 0;
    cout << "Enter 5 Number : " << endl;
    for (i = 0i < 5i++)
    {
        cout << i+1 << ". ";
        cin >> a[i];
    }
    for (i = 0i < 5i++)
    {
        if (a[0]<a[i])
     
           a[0]=a[i] ;
      
    }

    cout << "\n largest number = " <<a[0];
    return 0;
}

OUTPUT

Enter 10 Number : 
1. 23
2. 56
3. 102
4. 78.4
5. 34.67

largest number = 102













Share:

0 Comments:

Post a Comment

Pageviews