Today we will create a program to find the “Area And Circumference Of Circle”. In this program, we will use the formulas of the area of circle and circumference. So, let’s start creating the program for the area and circumference of a circle.
C Program To Calculate Area And Circumference Of Circle:
Here is the logic of the program of “Area and circumference of the circle”. First of all declare the variables, in this program, we are using “area, radius, pi, and circumference“. We are using float data type but you can also use double data type because the final answer of this program is in points(decimal-state). So, that’s why we are using float data type instead of integer data type because integer data type can’t give you an accurate answer.
After taking the value of radius from the user, first, we find the area so the formula of the area of (circle=pi*r*r). Here we are using radius instead of r variable. So, when you enter the value of radius of circle you will get the area of the circle and by the print statement, you will see your answer on the screen.
After that, you have to find the circumference of a circle, but this time you are not taking the value of the radius again because you’ve already entered the radius. Here you will again take the radius from the user by scanf statement but we are not using the scanf statement. Circumference of circle is equal to (2*pi*r).
You’ll also get the value of circumference on your screen automatically when you enter the radius it will show you the area and circumference of the circle on the screen. So, this is the program for finding the area and circumference of circle.
Program:
#include<stdio.h> int main(){ //You Can Also Use double data type instead of float// float area,circumference,radius,pi=3.14; printf("Enter The Radius Of The Circle:\n"); scanf("%f",&radius); //Area of Circle's Formula// area=pi*radius*radius; printf("Area=%f\n",area); //Formula Of Circumference Of Circle// circumference=2*pi*radius; printf("Circumference=%f\n",circumference); return 0; }
Output:
Conclusion:
From the above program we are now able to write a C Program to Find the Area and Circumference of Circle. If you are looking for the Program to find the Area of the triangle then click on the link to direct to the program page.