this is to find the maximum of ten input values
but the programme gives the answer what I have entered last
how can I correct it?
#include<iostream>
using namespace std;
void inputheight(float height[],int size);
void findmax(float height[],int size);
int main()
{
float pheight[10];
inputheight(pheight,10);
findmax(pheight,10);
return 0;
}
void inputheight(float height[],int size)
{
for(int i=0;i<size;i++)
{
cout<<"Input Height: ";
cin>>height[i];
}
}
void findmax(float height[],int size)
{
float max;
for(int i=1;i<size;i++)
{
max=height[0];
if(max<height[i])
{
max=height[i];
}
}
cout<<"max is: "<<max;
}
Line 25 doesn't belong inside the loop, but before it. Please use [code] tags.
Last edited on