C program to find Area Of SemiCircle; Through this tutorial, we will learn how to find or calculate area Of semiCircle using standard formula, function and pointer in c programs.
Programs and Algorithm to Find Area Of SemiCircle
Use the following algorithm and programs to find or calculate area Of semiCircle using standard formula, function, and pointer in c:
- Algorithm to Find Area Of SemiCircle
- C Program to Find Area Of SemiCircle using Standard Formula
- C Program to Find Area Of SemiCircle using Function
- C Program to Find Area Of SemiCircle using Pointer
Algorithm to Find Area Of SemiCircle
Use the following algorithm to write a program to find the area Of semiCircle; as follows:
- Take input radious. Store it in variable.
- Calculate area of semicircle using area=(22*r*r)/(2*7);
- Finally, print the value of area of semicircle.
C Program to Find Area Of SemiCircle using Standard Formula
#include<stdio.h> int main() { int r; float area; printf("enter radius of the circle: "); scanf("%d",&r); area=(22*r*r)/(2*7); printf("area of a semicircle: %f\n",area); return 0; }
The output of the above c program; as follows:
enter radius of the circle: 5 area of a semicircle: 39.000000
C Program to Find Area Of SemiCircle using Function
#include<stdio.h> float area(float r) { return (22*r*r)/(7*2); } int main() { float a,r; printf("enter radius of the semicircle: "); scanf("%f",&r); a=area(r); printf("area of a semicircle: %f\n",a); return 0; }
The output of the above c program; as follows:
enter radius of the semicircle: 8 area of a semicircle: 100.57142
C Program to Find Area Of SemiCircle using Pointer
#include<stdio.h> void area(float *r,float *a) { *a=(22*(*r)*(*r))/(2*7); } int main() { float r,a=1; printf("enter radius: "); scanf("%f",&r); area(&r,&a); printf("area of a semicircle: %f\n",a); return 0; }
The output of the above c program; as follows:
enter radius: 10 area of a semicircle: 157.14285