C program to find the area of a circle; Through this tutorial, we will learn how to find or calculate the area of a circle using formula, function, and poiter in c programs.
Programs and Algorithm to Find the Area of a Circle
- Algorithm To Find Area Of a Circle
- C Programs to Find the Area of a Circle using Formula
- C Programs to Find the Area of a Circle using Function
- C Programs to Find the Area of a Circle using Pointer
Algorithm To Find Area Of a Circle
Use the following algorithm to write a program to find area of a circle; as follows:
- START PROGRAM.
- TAKE RADIUS AS INPUT FROM USER.
- FIND AREA OF A CIRLCE USING THIS FORMULA AREA=3.14*RADIUS*RADIUS.
- PRINT “AREA OF CIRCLE = “
- END PROGRAM.
C Programs to Find the Area of a Circle using Formula
#include<stdio.h> int main() { int r; float area; printf("Please enter radius of the circle: "); scanf("%d",&r); area=(22*r*r)/7; printf("The area of circle is: %f\n",area); return 0; }
The output of the above c program; as follows:
Please enter radius of the circle: 15 The area of circle is: 707.000000
C Programs to Find the Area of a Circle using Function
#include<stdio.h> float area(int r) { return (22*r*r)/7; } int main() { int r; float a; printf("Please enter radius of the circle: "); scanf("%d",&r); a=area(r); printf("area of the circle: %f\n",a); return 0; }
The output of the above c program; as follows:
Please enter radius of the circle: 5 area of the circle: 78.000000
C Programs to Find the Area of a Circle using Pointer
#include<stdio.h> void area(int *r,float *a) { *a=(22*(*r)*(*r))/7; } int main() { int r; float a=1; printf("Please enter radius of the circle: "); scanf("%d",&r); area(&r,&a); printf("The area of circle is: %f\n",a); return 0; }
The output of the above c program; as follows:
Please enter radius of the circle: 7 The area of circle is: 154.000000