C++ Program to Calculate Product and Sum of all Elements in an Array

Hi,Today we make a Program About How to calculate the sum of all values in an array in c++ Program.We Add Value and Show on Screen.it is very Easy we Try To make it.

C++ Program to Calculate Product and Sum of all Elements in an Array

#include<iostream>
#include<conio.h>
using namespace std;
main()
{
int A[5]={9,6,9,12,15};
int sum;
sum=A[0]+A[1]+A[2]+A[3]+A[4];
cout<<"sum="<<sum<<endl;
getch();
}

Output of program

How many elements you want to enter : 5
Enter any 5 elements in Array: 
1 4 2 7 5
Sum of all Elements are: 19