C program to find the area of a circle
The formula of the Area of a circle is
but some time diameter is given in this time we have to divide the diameter of a circle by 2 to get the radius.
r is a Radius and Radius is a length from the center to the edge of a circleπ is pi and it is a mathematic symbol whose value is 22/7 or 3.14
In this article area of the circle is calculated as below
1. C program to find the area of a circle (When the value of π is 3.14)
2. C program to find the area of a circle (When the value of π is 22/7)
3. C program to find the area of a circle using the diameter
4. C program to find the area of a circle using the function
5. C program to find the area of a circle using #define function
Note
This is a comment written inside //. It does not have to be written while programming. The reason for using it is for the convenience and understanding of another programmer
C program to find the area of a circle using radius (When the value of π is 3.14)
| #include<stdio.h> #include<conio.h> void main() { // Value of radius is stored in r variable float A, r; // taking input of radius from users printf("\n Enter radius of a
circle"); scanf("%f", &r); // using formula of circle A=(22*r*r)/7; // printing Area of circle printf("\n Area of circle = %f", A); getch();
}
|
Output
C program to find the area of a circle (When the value of π is 22/7)
We can use the value of π 22/7 instead of 3.14 but the answer comes slightly different and the program to find the area of a circle using the value of π is 22/7
Program
| #include<stdio.h> #include<conio.h> void main() { // Value of radius stored is in r variable float A, r; // taking input of radius from user printf("\n Enter radius of a circle"); scanf("%f", &r); //using formula of circle pi * radius * radius value of pi is 22/7 A=(22*r*r)/7; // printing area of a circle printf("\n Area of circle = %f", A); getch(); } |
Output
C program to find the area of a circle using a diameter
| #include<stdio.h> #include<conio.h> void main() { float d, r, A; // taking input of diameter from user printf("\n Enter a diameter of a
circle"); scanf("%f",&d); // converting diameter into radius r=d/2; //using formula of circle p * radius * radius value of p is 22/7 A=3.14*r*r; printf("\n Area of a circle is %f", A); getch();
} |
Output
C program to find the Area of circle using function
| #include<stdio.h> #include<conio.h> void area(float); //
function prototype void main() { float r; // taking input of radius from users printf("\n Enter a radius of a
circle"); scanf("%f", &r); area(r); // function call getch(); } void area(float r) { float A; //using formula of circle p * radius * radius value of p is 22/7 A=3.14*r*r; // Printing area of circle printf("\n Area of a circle is %f", A); getch();
} |
Output
C program to find the area of a circle using a #define function
|
#include<stdio.h> #include<conio.h> #define pi 3.14 void main() { float r, A; // taking input of diameter from user printf("\n Enter a radius of a
circle"); scanf("%f",&r); /* Using area of circle area = r*r and pi is a variable define under
#define function */ A=pi*r*r; // Printing Area of circe printf("\n Area of a circle is
%f", A); getch(); } |
Output







0 Comments
Please do not enter any spam link on comment box