Volume of Cone using C++ Programming Language

Volume of Cone :
V =  3.14 * r * r * h  /  3

where
r ==> radius
h==> height


Algorithm:
Two input values , radius and height , which are floating point numbers so type should be double.

Program code:

#include<iostream>
#include<conio.h>
using namespace std;

int main()
{
double rad , height , volume ;
char redo;
cout<<endl;
cout<<"*********************************"<<endl;
cout<<"         Volume of Cone          "<<endl;
cout<<"*********************************"<<endl<<endl;
do
{
  cout<<"  Enter radius  =  " ;
  cin>> rad;
  cout<<endl<<endl;
  cout<<"  Enter Height  =  ";
  cin>> height;
  cout<<endl<<endl;
  volume = ( 3.14 * rad * rad * height ) / 3 ;
  cout<<"  Volume of cone is  =  " << volume;
  cout<<endl<<endl;
  
  cout<<"*********************************"<<endl<<endl;
  cout<<"Enter y or Y to for another calculation  =  ";
  cin>>redo;
  cout<<endl<<endl;
    } while(redo == 'y' || redo == 'Y');
   

   getch();
}

Output: After compile and run , the output of above program code is like this

Click on pic to enlarge this.

Hope that you will find this helpful.

No comments:

Post a Comment

Please disable your ad blocker to support this website.

Our website relies on revenue from ads to keep providing free content.