Answer to Question #274637 in C++ for khan

Question #274637

Write a C Program to calculate the Average of an array elements where the elements are received as input.


1
Expert's answer
2021-12-07T09:21:05-0500
#include <iostream>
#include<cmath>
using namespace std;


int main(){
    
int n,b,c,a;
cout<<"Enter number of arrays"<<endl;
//cin>>n;
int i,sum=0;
int numbers[n];
for( i=1;i<=n;++i){
   cout<"enter number<<i<<endl;
   cin>>number[i];
   sum=sum+number[i];
}


cout<<"average="<<sum/i<<endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment