C Program To Find Area Of SemiCircle

In this tutorial, i am going to show you how to find or calculate area Of semiCircle with the help of standard formula, function and pointer in c programs.

All C Programs and Algorithm to Find Area Of SemiCircle

  • 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

Follow the below given algorithm to write a program to find the area Of semiCircle; as follows:

  1. Take input radious. Store it in variable.
  2. Calculate area of semicircle using area=(22*r*r)/(2*7);
  3. 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 result 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 result 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 result of the above c program; as follows:

enter radius: 10
area of a semicircle: 157.14285

More C Programming Tutorials

a

Leave a Comment