Home >Backend Development >C++ >In a C program, translate the following into Chinese: Area of ​​the circumcircle of a right triangle

In a C program, translate the following into Chinese: Area of ​​the circumcircle of a right triangle

WBOY
WBOYforward
2023-08-28 22:53:05749browse

Here we will learn how to obtain the area of ​​the circumcircle of a right triangle. The hypotenuse of the triangle forms the diameter of the circle. So if the hypotenuse is h, the radius is h/2

In a C program, translate the following into Chinese: Area of ​​the circumcircle of a right triangle

so the area is -

In a C program, translate the following into Chinese: Area of ​​the circumcircle of a right triangle

Example code

#include <iostream>
#include <cmath>
using namespace std;
float area(float h) {
   if (h < 0) //if h is negative it is invalid
      return -1;
   float area = 3.1415 * (h/2) * (h/2);
   return area;
}
int main() {
   float h = 8;
   cout << "Area : " << area(h);
}

Output

Area : 50.264

The above is the detailed content of In a C program, translate the following into Chinese: Area of ​​the circumcircle of a right triangle. 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