Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - A program for calculating the area of a circle
A program for calculating the area of a circle
1. The program for calculating the area of a circle in C language is as follows:

# contains "stdio.h"

# Define PI 3. 14 159

int main()

{

Floating NR;

Floating nostrils;

Printf ("Please enter the radius of the circle:");

scanf("%f ",& ampnR);

nArea = PI * nR * nR

Printf ("The area of the circle is: %f\n", narea);

Returns 0;

}

2.? The program for calculating the area of a circle in C++ language is as follows:

# include & ltiostream & gt

Use namespace std

Const double pi = 3.1415;

int main()

{

Double r;

CIN & gt; & gtr; ? //Enter the radius

Cout & lt& ltPI * r * r<& ltendl// output area

Returns 0;

}

It can also be calculated in other languages, and the idea is the same.

They all use the area formula of a circle: S=πr?

S represents the area of a circle, π represents pi, and r represents the radius of a circle.