8. Program that inputs ten floating point numbers in an array. It displays the values which are greater than the average value of the array.

Chapter 7: 

Arrays

Programming Exercise

Problem # 8:

Write a program that inputs ten floating point numbers in an array. It displays the values which are greater than the average value of the array.

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main ()
{
    float num[10], total=0, avg;
    int i;
    for(i=0;i<10;i++)
    {
        cout<<"Enter a floating point number:";
        cin>>num[i];
        total+=num[i];
    }
    avg=total/10;
    for(i=0;i<10;i++)
    {
        if(num[i]>avg)
        cout<<"\n"<<num[i]<<" Number is greater than the average value of the array.";
    }
}

Output:


Let me know in the comment section if you have any question.

Previous Post:
7. Program that uses three arrays Mango, Orange and Banana to store the numbers of fruits purchased by customer. The program finally displays the total bill of each customer according to the prices.


Comments

Post a Comment