Beta Coder

Learn code like Beta Coder.

Breaking

Saturday, June 13, 2020

C Program to Find Area and Circumference of a circle

CALCULATE AREA AND CIRCUMFERENCE OF A CIRCLE

C Program to Find  Area and Circumference of a circle


In this program we learn how to calculate area and circumference of a circle based on the radius value provided by user using C.

Area formula of a Circle

The area of a Circle is given by the bellow formula
Area= 3.14 * radius * radius

Circumference formula of a Circle
The circumference of a Circle is given by the bellow formula
Circumference= 2 * 3.14 * radius 
The area and circumference of a circle
Program to compute the area and circumference of a circle 
To compute area and circumference we must know the radius of circle. First user to enter the radius and based on the input it would calculate the values. To make it simple we have taken standard PI value as 3.143 (constant) in the program.  

// Find area and circumference of circle
#include “stdio.h”
#include “conio.h”
void main()
{
	float ar,ci,r,pi;
	clrscr();
	printf("\n Enter the value of radias : ");
	scanf("%f",&r);
	pi=3.14;
	ar=pi*r*r;
	ci=2*pi*r;
	printf("\n The area of the circle : %8.6f square unit",ar);
        printf("\n The circumference of the circle : %8.6f unit",ci);
	getch();
}
Output:
Enter the value of radias : 6
TheThe area of the circle : 113.09734 square unit
The circumference of the circle : 37.69911 unit

No comments:

Post a Comment