Compute Volume of Cylinder | C++

January 12th, 2021 11:56:44 AM

					
/* Algorithm: Step 1: Get radius of the cylinder from the user and store in variable r Step 2: Get height of the cylinder from the user and store in variable h Step 3: Multiply radius * radius * height * pi and store in v Step 4: Display the volume */ #include <iostream> using namespace std; int main() { float r; //define variable for radius float h; //define variable for height float v; float pi; pi=3.1416; cout<<"Enter radius:"; cin>>r; cout<<"Enter height:"; cin>>h; v=r*r*h*pi; //compute volume cout<<"Radius:"<<r<<"\tHeight:"<<h<<endl; //display radius and height cout<<"\n************************\n"; cout<<"Volume:"<<v<<endl;//display volume return 0; }

Featured Posts