Home > Backend Development > C#.Net Tutorial > How to calculate the area and circumference of a circle in c language

How to calculate the area and circumference of a circle in c language

藏色散人
Release: 2018-12-10 16:16:32
Original
49247 people have browsed it

C language may be difficult for novices to calculate the area and circumference of a circle. But in fact, as long as you understand the calculation principles of the area and circumference of a circle, it is easy to implement.

How to calculate the area and circumference of a circle in c language

In geometry, the area of ​​a circle is equal to πr², and the circumference of a circle is equal to 2πr. The Greek letter π here is a constant approximately equal to 3.14159.

Recommended course: "C Language Tutorial"

How to calculate the area and circumference of a circle in c language

Below we will introduce it to you through specific code examples. How to calculate the area and circumference of a circle in C language.

Write a C program to calculate the circumference and area of ​​a circle with a radius of 6 inches.

The code is as follows:

#include <stdio.h> 
int main() {
   int radius;
   float area, perimeter;    
   radius = 6;

   perimeter = 2*3.14*radius;
   printf("圆的周长 = %f 英寸\n", perimeter);
	
	area = 3.14*radius*radius;
	printf("圆的面积 = %f 平方英寸\n", area);

return(0);
}
Copy after login

The calculation result is as follows:

How to calculate the area and circumference of a circle in c language

Why is the area of ​​a circle multiplied by the square of the radius? ?

can be shown in the following animation:

How to calculate the area and circumference of a circle in c language

This article is about the specific method of calculating the area and circumference of a circle in C language. I hope it will help you if you need Friends help!

The above is the detailed content of How to calculate the area and circumference of a circle in c language. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template