Program to calculate area and volume of a cylinder.

Problem:

Write a program to calculate area and volume of a cylinder.

Solution:

#include<iostream>
#include<conio.h>
using namespace std;
int main()
{
float a,v,r=45.2,h=35.2;
const float PI=3.14;
v=PI*r*r*h;
a=2*PI*r*(r+h);
cout<<"the area of cylinder having radius:"<<r<<"and height:"<<h<<"is:"<<a<<endl;
cout<<"the volume of cylinder having radius:"<<r<<"and height:"<<h<<"is:"<<v<<endl;
getch();
}

Output:


Let me know in the comment section if you have any question.

Previous Post:
Program that inputs dividend and divisor. It then calculates and displays the quotient and remainder.

Next Post: