I'm trying to calculate the area of a circle in C as an assignment, I've written some code to help me do this, but it's not giving the expected results, It is supposed to give the following results in order for it to get approved:
This is what the result should be:
Input Result 5.0 Please enter the radius: The area of the circle is 78.539750
This is the result I am getting:
Please enter the radius: The area of the circle is 78.537498
Has anyone got any ideas? They would be greatly appreciated! :)
#include <stdio.h>
#include <math.h>
int main(void)
{
double PI = 3.14159;
/* declare the other required variables */
float area, radius;
/* get the input from the console */
printf("Please enter the radius:\n");
scanf("%f",&radius);
/* compute the area */
area = PI * radius * radius;
/* write out the answer */
printf("The area of the circle is %f\n", area);
return 0;
}