# Program to calculate volume of Octahedron

Given the side of the Octahedron then calculate the volume of Octahedron.

Examples:

Input : 3 Output : 12.7279 Input : 7 Output : 161.692

A regular Octahedron has eight faces,twelve edges and six vertices. It has eight triangles with edges of equal length and effectively two square pyramids meeting at their bases.

Image Source : Wikimedia

Properties of Octahedron:

Number of faces: 8

Number of edges: 12

Number of vertices: 6

Volume = √2/3 × awhere a is the side of Octahedron^{3}

## CPP

`// CPP Program to calculate ` `// volume of Octahedron ` `#include <bits/stdc++.h> ` `using` `namespace` `std; ` ` ` `// utility Function ` `double` `vol_of_octahedron(` `double` `side) ` `{ ` ` ` `return` `((side*side*side)*(` `sqrt` `(2)/3)); ` `} ` ` ` `// Driver Function ` `int` `main() ` `{ ` ` ` `double` `side = 3; ` ` ` `cout << ` `"Volume of octahedron ="` ` ` `<< vol_of_octahedron(side) ` ` ` `<< endl; ` `} ` |

*chevron_right*

*filter_none*

## Java

`// Java Program to calculate ` `// volume of Octahedron ` ` ` `import` `java.io.*; ` `class` `GFG ` `{ ` ` ` `public` `static` `void` `main (String[] args) ` ` ` `{ ` ` ` `// Driver Function ` ` ` `double` `side = ` `3` `; ` ` ` `System.out.print(` `"Volume of octahedron = "` `); ` ` ` `System.out.println(vol_of_octahedron(side)); ` ` ` ` ` `} ` ` ` ` ` `// utility Function ` ` ` `static` `double` `vol_of_octahedron(` `double` `side) ` ` ` `{ ` ` ` `return` `((side*side*side)*(Math.sqrt(` `2` `)/` `3` `)); ` ` ` `} ` `} ` ` ` `// This code is contributed ` `// by Azkia Anam. ` |

*chevron_right*

*filter_none*

## Python3

`# Python3 Program to calculate ` `# volume of Octahedron ` ` ` `import` `math ` ` ` `# utility Function ` `def` `vol_of_octahedron(side): ` ` ` `return` `((side` `*` `side` `*` `side)` `*` `(math.sqrt(` `2` `)` `/` `3` `)) ` ` ` `# Driver Function ` `side ` `=` `3` `print` `(` `"Volume of octahedron ="` `, ` ` ` `round` `(vol_of_octahedron(side),` `4` `)) ` ` ` `# This code is contributed ` `# by Azkia Anam. ` |

*chevron_right*

*filter_none*

## C#

`// C# Program to calculate ` `// volume of Octahedron ` `using` `System; ` ` ` `class` `GFG ` `{ ` ` ` `public` `static` `void` `Main () ` ` ` `{ ` ` ` `// Driver Function ` ` ` `double` `side = 3; ` ` ` `Console.Write(` `"Volume of octahedron = "` `); ` ` ` `Console.WriteLine(vol_of_octahedron(side)); ` ` ` ` ` `} ` ` ` ` ` `// utility Function ` ` ` `static` `double` `vol_of_octahedron(` `double` `side) ` ` ` `{ ` ` ` `return` `((side*side*side)*(Math.Sqrt(2)/3)); ` ` ` `} ` `} ` ` ` `// This code is contributed ` `// by vt_m. ` |

*chevron_right*

*filter_none*

## PHP

`<?php ` `// PHP Program to calculate ` `// volume of Octahedron ` ` ` `// utility Function ` `function` `vol_of_octahedron( ` `$side` `) ` `{ ` ` ` `return` `((` `$side` `* ` `$side` `* ` ` ` `$side` `) * (sqrt(2) / 3)); ` `} ` ` ` ` ` `// Driver Function ` ` ` `$side` `= 3; ` ` ` `echo` `(` `"Volume of octahedron ="` `); ` ` ` `echo` `(vol_of_octahedron(` `$side` `)); ` ` ` `// This code is contributed ` `// by vt_m. ` `?> ` |

*chevron_right*

*filter_none*

Output:

Volume of octahedron = 12.7279

## Recommended Posts:

- Program to calculate volume of Ellipsoid
- Program to calculate area and volume of a Tetrahedron
- Program to calculate Volume and Surface area of Hemisphere
- Calculate Volume of Dodecahedron
- Calculate volume and surface area of Torus
- Calculate volume and surface area of a cone
- Calculate Volume and Surface area Of Sphere
- Program for Surface Area of Octahedron
- Calculate Volume, Curved Surface Area and Total Surface Area Of Cylinder
- Program for volume of Pyramid
- Program for Volume and Surface Area of Cube
- Program for Volume and Surface Area of Cuboid
- Program to find the Volume of a Triangular Prism
- Program to find the Volume of an irregular tetrahedron
- Program to find the Area and Volume of Icosahedron

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.