|
Area of Circle
#include <stdio.h>
#define PI 3.14159
int main()
{
float sum , radius ;
printf("This program works out the area of a circle.\n");
printf("Enter the radius of the circle.\n");
scanf("%f",&radius);
/*area of a circle is pi * radius * radius*/
sum = PI * radius * radius;
/*display the area*/
printf("The area of a circle is %f.\n",sum);
return 0;
}
Circumference of circle
/*work out circumference and area of a circle*/
#include <stdio.h>
#define PI 3.14159
int main(void)
{
float area , circumference , radius;
printf("What is the radius of the circle.\n");
scanf("%f",&radius);
area = PI * radius * radius;
circumference = 2.0 * PI * radius;
printf("The circumference of the circle is %1.2f.\n",circumference);
printf("The area of the circle is %1.2f.\n",area);
return 0;
}
|