C++ Programming Code Examples C++ > Arrays and Matrices Code Examples Sum of Array - Calculate sum for all the array elements Sum of Array - Calculate sum for all the array elements // Header Files #include <iostream> #include<conio.h> using namespace std; #define ARRAY_SIZE 5 int main() { int array[ARRAY_SIZE]; int j; float total = 0.0, average; cout<<"Sum of Array In C++ Example Program\n"; for (j = 0; j < ARRAY_SIZE; j++) { cout<<"Enter the Number : "<< (j+1) <<" : "; cin>>array[j]; } /* Sum of the Array Using for Loop */ for (j = 0; j < ARRAY_SIZE; j++) { total = total + array[j] ; } average = total / ARRAY_SIZE; cout<<"\n Sum of all Numbers = "<< total<<"\n"; cout<<"\n Average of all input numbers = "<< average<<"\n"; getch(); }