Program Description:
In this program we are going to find out the diameter, circumference and area of a circle.
We will use the following formulas:
- Diameter= 2*radius
- Circumference= 2*3.141*radius
- Area=3.141*radius*radius
There is one more feature in the program i.e after the program ends, we will ask the user whether he wants to check another data. if he enters 1, then we will run the program again else we will terminate the program by printing THANK YOU
Source code:
// C program to find out the area of a circle#include<stdio.h>
int main()
{
float radius,diameter,area,circumference;
int i=1;
while(i=1)
{
printf("\nEnter the radius of the circle in centimeters:");
scanf("%f",&radius);
diameter=2.0*radius;
area=3.141*radius*radius;
circumference=2*3.141*radius;
printf("The diameter of the circle is %f\n",diameter);
printf("The circumference of the circle is %f\n",circumference);
printf("The area of the circle is %f\n\n",area);
printf("Do you want to check the properties of another circle?(0/1)");
scanf("%d",&i);
if(i!=1)
break;
}
printf("Thank You");
}
0 Comments