Q: Write a program that inputs ten floating point numbers in an array. It displays values which are greater than the average value of the array.
Program:
#include<iostream.h>
#include<conio.h>
void main()
{
float array[10], sum=0,average;
int i,
cout<<"Enter floating point numbers for each index of the array: ";
for(i=0; i<10; i++)
{
cin>>array[i];
sum+=array[i];
}
average=sum/10;
cout<<" Values greater than the average value of the array are: "<<endl;
for(i=0; i<10; i++)
if(array[i]>average)
cout<<array[i]<<endl;
getche();
}
No comments:
Post a Comment