# Answer to Question #23079 in C++ for felix chimezie oguamanam

Question #23079

Write a program to calculate the surface area and volume of a cylinder using a macro

surface_area = 2 * Pi * r * (r + h)

Volume = Pi * r * r * h

surface_area = 2 * Pi * r * (r + h)

Volume = Pi * r * r * h

Expert's answer

#include <iostream>

#include <math.h>

using namespace std;

int main()

{

cout << "enter r and h" << endl;

double r;

cin>>r;

cout<<endl;

double h;

cin>>h;

double Pi=3.14;

double surface_area = 2*Pi*r*(r+h);

double Volume = Pi*r*r*h;

cout<<"surface_area= "<<surface_area<<endl;

cout<<"Volume= "<<Volume<<endl;

return 0;

}

#include <math.h>

using namespace std;

int main()

{

cout << "enter r and h" << endl;

double r;

cin>>r;

cout<<endl;

double h;

cin>>h;

double Pi=3.14;

double surface_area = 2*Pi*r*(r+h);

double Volume = Pi*r*r*h;

cout<<"surface_area= "<<surface_area<<endl;

cout<<"Volume= "<<Volume<<endl;

return 0;

}

## Comments

## Leave a comment