Program to calculate volume of Ellipsoid in C++

C++Server Side ProgrammingProgramming

Given with r1, r2 and r3 the task is to find the volume of ellipsoid. An ellipsoid is a quadric surface, a surface that may be defined as the zero set of a polynomial of degree two in three variables. Among quadric surfaces, an ellipsoid is characterized by either of the two following properties.

Formula used to calculate volume of ellipsoid

Volume of Ellipsoid : (4/3) * pi * r1 * r2 * r3

Example

Input-: r1 = 6.3, r2 = 43.4, r3 = 3.7
Output-: volume of ellipsoid is : 4224.87

Algorithm

Start
Step 1 -> define macro as
   #define pi 3.14
Step 2 -> Declare function to calculate Volume of ellipsoid
   float volume(float r1, float r2, float r3)
      return 1.33 * pi * r1 * r2 * r3
Step 3 -> In main()
   Declare variable as float r1 = 6.3, r2 = 43.4, r3 = 3.7
   Volume(r1, r2, r3)
Stop

Example

#include <bits/stdc++.h>
#define pi 3.14
using namespace std;
// Function to find the volume of ellipsoid
float volume(float r1, float r2, float r3){
   return 1.33 * pi * r1 * r2 * r3;
}
int main(){
   float r1 = 6.3, r2 = 43.4, r3 = 3.7;
   cout << "volume of ellipsoid is : " << volume(r1, r2, r3);
   return 0;
}

Output

volume of ellipsoid is : 4224.87
raja
Published on 20-Sep-2019 14:22:56
Advertisements