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

  

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


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

OUTPUT

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

 sum = 294.07













Share:

0 Comments:

Post a Comment

Pageviews