c++ program to find the sum and average of one dimensional integer array



QUESTION
Write the c++ program to find the sum and average of one dimensional integer array

PROGRAM
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
int Arr[10],n,sum=0;
cout<<"Enter number of elements = ";
cin>>n;
for(int i=0;i<n;i++)
{
cout<<"Enter element "<<i+1<<":";
cin>>Arr[i];
}
for(int i=0;i<n;i++)
sum+=Arr[i];

cout<<"\nThe sum of Array is :"<<sum;
cout<<"\nThe average of Array is :"<<sum/n;
getch();


return 0;


Powered by Blogger.