hi, i have written a program to find area of triangle, but i meet some errors, i can not fix this error, kindly help me to fix the error. thanks.

``````//******area of triangle******//
#include<iostream>
using namespace std;

float trianglearea (float a, float b, float c, float d)
{

float r=a*b*c*d;
float x = r;
float y = 1;
while (y*y<=x)
{
y=y+1;
}
y=y-1;
cout<<y;
float result;
result=y;
return (result);
}

int main()
{

float a, b, c;
cout<<"enter first side of triangle: ";
cin>>a;
cout<<"enter second side of triangle: ";
cin>>b;
cout<<"enter third side of triangle: ";
cin>>c;
float s=(a+b+c)/2;
float d=s-a;
float e=s-b;
float f=s-c;
float area_triangle = trianglearea (s*d*e*f);
cout<<area_triangle;

return 0;

}
``````

but i meet some errors

Could you please state the kind of errors you are encountering?

this is the error
too few arguments to function float triangle(float,float,float,float)

Look at line 37 of your posted code. You do a multiplication s.d.e.f, resulting in one argument instead of four. use commas instead.

thanks dude, i fixed it.

Not completely sir, you still have to mark this thread as solved.

You end the function with:

``````    y=y-1;
cout<<y;
float result;
result=y;
return (result);
``````

Your function is meant to return the solution, not display it, so you should remove the output statement.

Secondly, why assign the value y to another variable, only to return that variable? How about, simply:

``````    y=y-1;
return (y);
``````

Or even:

``````   return ( y - 1 );
``````

One caveat to bear in mind with the algorithm you're using. If any one of the sides is half of the perimeter the algorithm will return 0. For Example 10, 20 ,30, s will equal 30, when you subtract c from s you end up with 0, which makes the product of a,b,c,d euqal 0. Which makes y = 0