In our earlier post we calculated the area and perimeter of a circle.In this post we are dealing with calculating the area and perimeter of a circle.
The main input for calculating area and perimeter of a circle is radius of the circle.We use the datatype float to store the radius of the circle.The formula to find the area of the circle is 3.14*r*r and the formula to find perimeter of the circle is 2*3.14*radius.After calculating the area and perimeter we need to display the results to the user.
#include<stdio.h> #include<conio.h> void main() { float radius,area,perimeter; //variable to store radius,area and perimeter clrscr(); printf("\nEnter the radius of the circle:"); scanf("%f",&radius); area = 3.14*radius*radius; perimeter = 2*3.14*radius; printf("\nArea of the given cirlce is:%f",area); printf("\n\nPerimeter of the given circle is:%f",perimeter); getch(); }
OUTPUT:
You can download the program:download
If you have any doubts you can place them in comments.
dont we have to initialize the variables we have taken??
No need to intialize the variables……Because we are requesting new value radius and after multiplication new value for area and new value for perimeter are assigned.
Hope it helps
The area of perimeter is a good modificatin programmer in progam.
it real helped