In: Computer Science
Write a C++ program to read N numbers. Find sum, product, and average of N numbers
#include<iostream>
using namespace std;
int main ()
{ int i,n,pro=1,num ;
float sum=0, avg;
cout<<" Enter the number of values:";
cin>>n;
cout<<"Enter values :";
for(i=0;i<n;i++)
{
cin>>num;
sum=sum+num;
pro=pro*num;
avg=sum/n;
}
cout<<"\nSum:"<< sum;
cout<<"\nProduct:"<< pro;
cout<<"\nAverage:"<< avg;
}
output: