Code:
#include <iostream>
#include <cmath>
#define pi 3.14159
using namespace std;
int main(){
float r, h, l, vol, sa;
cout << "Enter the radius of the cone: ";
cin >> r;
cout << "Enter the height of the cone: ";
cin >> h;
l = sqrt(pow(r,2)+pow(h,2)); //slant height
vol = (pi*r*r*h)/3;
sa = (pi*r*l)+(pi*r*r);
cout << "The Volume is " << vol << " and The Surface area is "<<sa;
}
#include <iostream>
#include <cmath>
#define pi 3.14159
using namespace std;
int main(){
float r, h, l, vol, sa;
cout << "Enter the radius of the cone: ";
cin >> r;
cout << "Enter the height of the cone: ";
cin >> h;
l = sqrt(pow(r,2)+pow(h,2)); //slant height
vol = (pi*r*r*h)/3;
sa = (pi*r*l)+(pi*r*r);
cout << "The Volume is " << vol << " and The Surface area is "<<sa;
}
Output:
Enter the radius of the cone: 2
Enter the height of the cone: 7
The Volume is 29.3215 and The Surface area is 58.3086
Process returned 0 (0x0) execution time : 3.997 s
Press any key to continue.