計算內接於正方形的圓的面積的程式


內接於正方形的圓是指兩端與正方形的邊相切的圓。即內接圓的直徑等於正方形的邊長。使用公式可以計算面積“((π/4)*a*a)”,其中“a”是正方形的邊長。

程式碼邏輯 - 使用公式((π/4)*a*a) 來計算內接圓的面積,為此我們需要定義數學上為 22/7 或 3.14 的π(π)的值。計算結果的表示式儲存在一個浮點變數中。

示例

 現場演示

#include <stdio.h>
#include <math.h>
int main() {
   int a = 5;
   float area;
   float pie = 3.14;
   printf("Program to find area of circle inscribed inside a square
");    printf("The side of the square is %d
", a);    area = ((pie/4)*a*a);    printf("The area of circle inscribed inside a square is %f
", area);    return 0; }

輸出

The side of the square is 5
The area of circle inscribed inside a square is 19.625000

更新於: 30-Jul-2019

533 次觀看

開啟您的 職業生涯

完成課程並獲得認證

立即開始
廣告
© . All rights reserved.