C++ Program to Compute Volume and Surface Area of Cylinder

Write C++ Program to Compute Volume and Surface Area of Cylinder

// CPP Program to Compute Volume and Surface Area of Cylinder

#include <iostream>
#define PI 3.14

using namespace std;

int main()

{
   float radius = 4, height = 5;

   double area_cylinder;

   //cylinder area formula
   area_cylinder = (2 * PI * radius * height) + (2 * PI * radius * radius);

   double volume;
   //cylinder volume formula
   volume = ( PI * radius * radius * height);

   cout << "Surface area of Cylinder having radius " << radius <<
            " and height " << height << " :--> "<<  area_cylinder;
   cout << "\nVolume of Cylinder having radius " << radius <<
            " and height " << height << " :--> " << volume;

   return 0;
}

Output:

Surface area of Cylinder having radius 4.00 and height 5.00 :--> 226.08
Volume of Cylinder having radius 4.00 and height 5.00 :--> 251.20

≪ Previous | Next ≫