Answer to Question #57641 in C++ for Sajid 8

Question #57641
Q. Write a program that inputs 10 floating point numbers in an array. It displays the values which are greater than the average value of the array.
1
Expert's answer
2016-02-08T07:36:23-0500
#include <iostream>


int main()
{
double array[10];
double avarage = 0;

std::cout << "Please, enter 10 floating point numbers:" << std::endl;
for(int i = 0; i < 10; i++)
{
std::cin >> array[i];
avarage += array[i];
}
avarage = avarage / 10;

std::cout << std::endl << "Values which are greater than the average value of the array:" << std::endl;

for(int i = 0; i < 10; i++)
{
if ( array[i] > avarage )
{
std::cout << array[i] << std::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

LATEST TUTORIALS
APPROVED BY CLIENTS