用 C 程式查詢圓的面積。


圓是一個封閉圖形。圓上的所有點距離圓內的一點等距。中心點稱為圓的中心。點到中心的距離稱為半徑。

面積是封閉圖形尺寸跨度的定量表示。

圓的面積是指封閉在圓的尺寸內的面積。

計算圓面積的公式為:

Area = π*r*r

為了計算面積,我們將圓的半徑作為輸入並使用公式計算面積:

演算法

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.

示例

使用的變數:

int r,圓的半徑

float area,使用該公式計算的圓的面積。

 即時演示

#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;
}

輸出

The area of the circle is 200.96

更新於:19-Sep-2019

12K+ 次瀏覽

開啟您的 職業生涯

完成課程,取得證書

開始
廣告