Monday 25 April 2016

C++ Programming How to find a Sum using an Array

This Program will show you how to find a sum of Different Numbers using Arrays in C++ Language


Program # 4 : Find the Sum using an Array 


#include <iostream>

using namespace std;

int main()
{
    int avg[] = {6,14,100,40,40};
     int sum = 0;
    for(int x=0; x<5; x++){
        sum += avg[x];
        cout << sum << endl;
    }


}

Note : you can use any Numbers to find their Sun.

Output of the Program : 


0 comments:

Post a Comment