C Program To Find Area And Perimeter Of Circle
#include<stdio.h> #include <conio.h> #define PI 3.141 void main() { float a,r,c; clrscr(); printf("\n Enter The Radius : "); scanf("%f",&r); a=PI*r*r; //area of circle formula c=2*PI*r; //circumference of circle formula printf("\n Area of circle = %0.2f units/sq",a); printf("\n\n Circumference Of circle = %0.2f units",c); getch(); }
Output :
In the above program, we have used the following formulas.
- Area Of Circle A= π * r * r
- Circumference Of Circle C = 2 * π * r
(Here PI(π) is constant and is equal to 3.141.)
#include<stdio.h> #include <conio.h> #define PI 3.141 float area(float n); float peri(float m); void main() { float a,r,c; clrscr(); printf("\n Enter The Radius : "); scanf("%f",&r); a=area(r); //area of circle formula c=peri(r); //circumference of circle formula printf("\n Area of circle = %0.2f units/sq",a); printf("\n\n Circumference Of circle = %0.2f units",c); getch(); } float area(float n) { return(PI*n*n); } float peri(float m) { return(2*PI*m); }
In this way, we can find the area and perimeter of a circle using this simple method in c programming.