# Answer to Question #25025 in C++ for cwojo

Question #25025

write a program that accept 5 numbers and display the sum and average of the numbers

Expert's answer

#include <iostream>

const int SIZE=5;

int main()

{

double numbers[5];

std::cout <<"Enter " <<SIZE <<" numbers:\n";

int i;

for( i=0; i<SIZE; ++i )

{

std::cin >>numbers[i];

}

double sum=0;

for( int i=0; i<SIZE; ++i )

{

sum+=numbers[i];

}

std::cout <<"Sum=" <<sum <<std::endl;

std::cout <<"Average=" <<sum/SIZE <<std::endl;

return 0;

}

const int SIZE=5;

int main()

{

double numbers[5];

std::cout <<"Enter " <<SIZE <<" numbers:\n";

int i;

for( i=0; i<SIZE; ++i )

{

std::cin >>numbers[i];

}

double sum=0;

for( int i=0; i<SIZE; ++i )

{

sum+=numbers[i];

}

std::cout <<"Sum=" <<sum <<std::endl;

std::cout <<"Average=" <<sum/SIZE <<std::endl;

return 0;

}

Need a fast expert's response?

Submit orderand get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

## Comments

## Leave a comment