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

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

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

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

#include <iostream>
#include <math.h>
#define PI 3.14

using namespace std;

int main()
{

    float radius, height;
    float surface_area, volume;

    cout << "Enter radius of a cone :--> ";
    cin >> radius;

    cout << "Enter height of a cone :--> ";
    cin >> height;

    //cone area formula
    surface_area = PI * radius * (radius + sqrt(radius * radius + height * height));

    //cone volume formula
    volume = (1.0/3) * PI * radius * radius * height;

    cout << "\nSurface area of cone :--> " << surface_area;

    cout << "\nVolume of cone :--> " << volume;

    return 0;
}

Output:

Enter radius of a cone :--> 5
Enter height of a cone :--> 8

Surface area of cone :--> 226.61
Volume of cone :--> 209.33