Write a program to compute the volume of a cylinder. Your program reads the radius and length and computes using the formula:
Area =radius*radius*pi
Volume= area *length
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
float r, h;
float area, volume ;
// Enter the value of radius
cout<< "Enter the radius :" ;
cin >> r ;
// Enter the value of height
cout<< "Enter the height :" ;
cin >> h ;
// calculating area
area = M_PI * r * r ;
// calculating volume of cylinder
volume = area * h ;
cout<<" Volume of cylinder is "<< volume << endl;
}
Comments
Leave a comment