Answer:
// here is code in c++
// headers
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// variables
int n,num;
double sum=0, avg;
long long int prod=1;
cout<<"Enter value of N:";
// read value of N
cin>>n;
cout<<"enter "<<n<<" numbers:";
// read the N numbers
for(int x=0;x<n-1)
{
cin>> num;
// calculate sum of all
sum=sum+num;
calculate product of all
prod=prod*num;
}
// print sum
cout<<"sum of all "<<n<<" numbers is: "<<sum<<endl;
// print product
cout<<"product of all numbers is : "<<prod<<endl;
print average
cout<<"average of all "<<n<<" numbers is: "<<sum/n<<endl;
return 0;
}
Step-by-step explanation:
Read the value of n from user.Then ask user to enter n numbers. Then calculate sum of all entered number and their product.After this calculate the average of entered number by dividing sum with n.Print sum, product and average of n numbers.
Output:
enter value of N:6
enter 6 numbers:1 2 3 4 5 6
sum of all 6 numbers is: 15
product of all numbers is : 120
average of all 6 numbers is: 2.5