Wednesday, March 14, 2012

Diameter, Circumference, and Area of a Circle

Reads the radius of a circle as a float value and computes and prints the diameter, the circumference ,and the area.
π = 3.14159
/*Program to compute circle diameter,circumference, and area from radius*/
#include<stdio.h>
#define PI 3.14159
int main(){
   float radius;
   printf("Enter the radius of your circle: ");
   scanf("%f",&radius);
   printf("The diameter of your circle is %.2f\n",radius * 2);
   printf("The circumference of your circle is %.2f\n",2 * PI * radius);
   printf("The area of your circle is %.2f\n",PI * radius * 2);
   system("pause");
   return 0;         
}

No comments:

Post a Comment