C++ Examples

WAP in C++ to Calculate the Volume of a Cylinder

The Program in C++ to Calculate the Volume of a Cylinder is given below:

#iclude <iostream>
using namespace std;

    int main()
    {
    	int rad1,hgt;
    	float volcy;
		cout << "\n\n Hello Codeauri Family, You ca Calculate the volume of a cylinder here :\n";
		cout << "-----------------------------------------\n";		
        cout<<" Please give the  radius of the cylinder here : ";
    	cin>>rad1;
		cout<<" and height of the cylinder as well : ";
    	cin>>hgt;
    	volcy=(3.14*rad1*rad1*hgt);
        cout<<" Wow,the volume of a cylinder is : "<< volcy << endl;
        cout << endl;
        return 0;
    }

Output:

Hello Codeauri Family, You ca Calculate the volume of a cylinder here :

Please give the radius of the cylinder here : 8
and height of the cylinder as well : 8
Wow,the volume of a cylinder is : 1607.68

Pro-Tips💡

This code is a simple C++ program that calculates the volume of a cylinder given its radius and height.

The program prompts the user to input the values for the radius and height of the cylinder,

then uses the formula for the volume of a cylinder, which is pi * r^2 * h to calculate the volume, and displays the result on the screen.

It starts with #include <iostream> which allows the program to perform standard input/output operations.

The using namespace std; allows the program to use the names of functions and objects from the standard C++ library without having to qualify them with the std:: prefix.

The main() function is where the program execution starts, it declares the necessary variables, prompts the user for input, performs the calculation

and displays the result and the program ends with return 0 indicating successful completion.

Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

Related Posts

C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

C# Program to Delete Element at Desired position From Array

The Program in C# Program to Delete Element at Desired position From Array is given below: Output: Hello Codeauri Family, enter the number of elements in the array:4Enter…

Leave a Reply

Your email address will not be published. Required fields are marked *

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X