# C++ Program to Find Volume of Cone

Howdy readers, today you will learn how to write a program to find the volume of a cone using the C++ Programming language.

The volume of a cone is one-third of the product area of circular base and height.

• Volume of Cone = (1/3)πr2h, where ‘h’ is the height of the cone and ‘r’ is the radius of the base.

The below program takes the radius of the base and height of the cone as input and then finds the volume using the above formula.

So, without any delay, let’s begin this tutorial.

## C++ Program to Find Volume of Cone

C++  Program

// C++ Program to Find Volume of Cone
#include <iostream>
using namespace std;

int main(){

// Taking input from the user
cout << "Enter the radius of the cone: ";
cout << "Enter the height of the cone: ";
cin >> height;

// Calculating volume

// Displaying result
cout << "The Volume of the cone is: " << vol << endl;

return 0;
}

Output

Enter the radius of the cone: 5
Enter the height of the cone: 8
The volume of the cone is: 209.333

Explanation

In the above program, we have declared three float data type variables named radius, height, and vol.

// Taking input from the user
cout << "Enter the radius of the cone: ";
cout << "Enter the height of the cone: ";
cin >> height;

This program prompts the user to enter the radius and height of the cone. These values get stored in the radius and height named variables.

// Calculating volume

The volume of cone is computed using the formula:

Volume of Cone = (1/3)πr2h, where ‘h’ is the height of the cone and ‘r’ is the radius of the base.

// Displaying result
cout << "Volume of the cone is: " << vol << endl;

After that, the volume obtained is printed on the screen using the cout function.

## Conclusion

I hope after reading this post, you understand how to write a program to find the volume of a cone using the C++ Programming language.

If you have any queries regarding the tutorial, then let us know in the comment section. We will be pleased to solve all of your queries.