Calculate the area of a circle circumference
Threads: Enter the radius of the circle. Calculate the circumference and area of a circle that
Threads quite clear and there is nothing to discuss more. Thing you have to do is remember the formula for the circumference and area of a circle. I have the following formula:
P = 2πR S = πR²
So the formula has. Now we just code formula.
/* * Calculator P and S of Circle */ #include <stdio.h> #include <math.h> int main() { float r, p, s; printf("Enter r = "); scanf("%f", &r); p = 2 * M_PI * r; s = M_PI * r * r; printf("Perimeter of circle = %f\n", p ); printf("Acreage of circle = %f\n", s ); return 0; }
In the code above, you notice yourself using constant M_PI available in the library math.h to be high precision.
From all the above, you do the following exercise.
Exercise: Calculate perimeter and area 10 circle but only using single 1 R is the radius turn
Recent Comments