C++ program to calculate the volume and Surface area of a cylinder,the program will take input such as radius,height and give output as volume.
#include<iostream.h>
#include <iomanip>
#include<math.h>
using namespace std;
const double PI = 3.14159;
int main ( )
{
double height;
double radius;
cout << "Enter the height of the cylinder: ";
cin >> height;
cout << "Enter the radius of the base of the cylinder: ";
cin >>radius;
cout << "Volume of the cylinder = " << PI * pow (radius, 2.0) * height << endl;
cout << endl;
cout << "Surface area: " << 2 * PI * radius * height + 2 * PI * pow (radius, 2.0) << endl;
cout << endl;
cout << fixed << showpoint << setprecision(2);
}
0 comments:
Post a Comment