C++ Program of Sum, Multiplication, Average Program in Array

In this program we will learn how to calculate sum, multiply and average of numbers stored in array.

The code is given below.

//Code Starts

#include<iostream>

#include<conio.h>

using namespace std;

int main()

{

  int n,a[n],sum=0,mul=1;

  float avg;

 

  cout<<“Enter Size of Array : “;

  cin>>n;

 

  for(int i=0;i<n;i++)

  {

    cout<<“Enter Number at “<<i<<” index : “;

    cin>>a[i];

  

    sum=sum+a[i];

    mul=mul*a[i];

  }

 cout<<“Sum = “<<sum<<endl;

 cout<<“Multiplication = “<<mul<<endl;

 avg=sum/n;

 cout<<“Average = “<<avg;

 getch();

}

//Code Ends

OUTPUT:

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s