Home >Backend Development >C++ >In C programming, find the area of ​​a circle

In C programming, find the area of ​​a circle

WBOY
WBOYforward
2023-08-25 22:57:101296browse

In C programming, find the area of ​​a circle

A circle is a closed shape. All points on a circle are equidistant from a point inside the circle. The center point is called the center of the circle. The distance from a point to the center of a circle is called the radius.

Area is a quantitative representation of the size span of a closed figure.

The area of ​​a circle is the area enclosed within the dimensions of the circle.

Formula to calculate the area of ​​a circle,

Area = π*r*r

To calculate the area, we are given the radius of the circle as input, we will use the formula to calculate the area,

Algorithm

STEP 1: Take radius as input from the user using std input.
STEP 2: Calculate the area of circle using,
   area = (3.14)*r*r
STEP 3: Print the area to the screen using the std output.

Example

Variables used -

int r, the radius of the circle

float area, the area of ​​the circle calculated using the formula. p>

Live demonstration

#include <stdio.h>
int main(){
   int r = 8;
   float area = (3.14)*r*r;
   printf("The area of the circle is %f",area);
   return 0;
}

Output

The area of the circle is 200.96

The above is the detailed content of In C programming, find the area of ​​a circle. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete