EDIT: I figured it out. This can be deleted.
My compiler does not like line 38: p = per(a, b, c);
BTW, this program is supposed to find the area and perimeter of a right triangle. If someone could test it if they know what is wrong and make sure it works, I would appreciate it as my compiler never tells me the final "answer" or whatever even when I use getchar(). If you could help me, I would appreciate it. I cannot for the life of me figure out what is wrong with it.
Code:
#include <stdio.h>
#include <math.h>
float areaTri(float a, float b)
{
float area;
area = .5 * a * b;
return area;
}
float hypotenuse(float a, float b)
{
float c;
c = sqrt (a*a + b*b);
return c;
}
float per(float a, float b, float c)
{
float p;
p = a + b + c;
return p;
}
void triangle()
{
float a, b, c, area;
printf("Please enter the length of the base of the triangle: ");
scanf("%f%", &a);
fflush(stdin);
printf("Please enter the heighth of the triangle: ");
scanf("%f", &b);
fflush(stdin);
area = areaTri(a, b);
c = hypotenuse(a, b);
p = per(a, b, c);
printf("The area of the triangle is: %6.1f\n", area);
printf("Side c of this triangle is %6.1f\n", c);
printf("The perimeter of this triangle is %6.1f\n", p);
}
int main()
{
triangle();
return 0;
}