Answer to Question #26056 in C++ for muhammad ismail iqbal

Question #26056
Write a C++ program to find the sum and average of one dimensional integer array
1
Expert's answer
2013-03-11T12:54:24-0400
#include <iostream>

using namespace std;

void main()
{
intA[10]={10,22,3,44,5,55,34,4,43,4};
int length= 10;
int sum =0;
int avg =0;

for(int i =0; i < length; i++)
{
sum+= A[i];
}

avg = sum /length;

cout<< "Sum: " << sum << endl;
cout<< "Average: " << avg << endl;
}

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

LATEST TUTORIALS
APPROVED BY CLIENTS