Homework help pic above Design a class that has an array of floatmg-pomt numbers
ID: 3552047 • Letter: H
Question
Homework help pic above
Design a class that has an array of floatmg-pomt numbers The constructor should accept an integer argument and dynamically allocate the array to hold that many numbers The destructor should free the memory held by the array In addtion there should be member functions to perform the Wlowrvg operations Store a number in any element of the array Retrive a number from any element of the array Return the highest value stored m the array Return the lowest value stored in the array Return the a.erage of all the numbers stored in the array Demonstrate the class in a program Sample RunExplanation / Answer
#include<iostream.h>
#include<conio.h>
void main()
{
float a[],high,low,avg,n;
cout<<"enter how many number in the array";
cin>>n;
cout<<"enter number";
for(int i=0;i<n;i++)
cin>>a[i];
cout<<"highest number";
float temp=a[0];
for(int i=0;i<n;i++)
{
if (a[i]>temp)
high=a[i];
}
cout<<temp;
cout<<"lowest number";
float temp=a[0];
for(int i=0;i<n;i++)
{
if (a[i]<temp)
low=a[i];
}
cout<<low;
cout<<"average";
avg=o;
for(int i=0;i<n;i++)
avg+=a[i];
avg=avg/n;
cout<<avg;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.