I need to find the area of the octagon using the current functions I have and with the same parameters, every time I input something it just outputs as "0.000000," how do I fix this? It is also not error checking properly.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int die(const char * msg);
double areaFromSide(double length);
int main()
{
double length = 0;
printf("Enter length of one side of the octagon: ");
scanf("%f", &length);
if (length > 0 && length <= 100)
{
double area = areaFromSide(length);
printf("Area of the octagon is: %f\n", area);
}
else
{
die("Input Failure!");
}
return 0;
}
double areaFromSide(double length)
{
double area = 0;
area = 2 * (1 + (sqrt(2)))*pow(length, 2);
return area;
}
int die(const char * msg)
{
printf("Fatal error: %s\n", msg);
exit(EXIT_FAILURE);
}