Site hosted by Angelfire.com: Build your free website today!

Here I have a program that will find the volume of a sphere, a cylinder, a cone, a pyramid and a Cube or Box, whatever you want to call it. Hope you have an easier time finding the volume of these shapes with this program.



Want to Download the Program?


This is the Code for The Program.


#include <stdio.h> #include "iostream.h" double sphere(double radius); double cylinder(double radius, double height); double cone(double radius, double height); double pyramid(double length, double width, double height); double box(double width, double height, double length); int main(void) { double radius,length,width,height; int volume; do{ cout<<"\t\tWhat volume would you like to find? (enter #) \n\n"; cout<<"\t\t\t ****************************\n"; cout<<"\t\t\t *\t (1). Sphere *\n"; cout<<"\t\t\t *\t (2). Cylinder *\n"; cout<<"\t\t\t *\t (3). Cone *\n"; cout<<"\t\t\t *\t (4). Pyramid * \n"; cout<<"\t\t\t *\t (5). Box *\n"; cout<<"\t\t\t ****************************\n\n\t\t\t\t\t"; cin>>volume; switch(volume) { case 1: cout<<"What is the Radius of the Sphere? "; cin>>radius; cout<<"The Volume Of THe Sphere is "<<sphere(radius); cout<<endl<<endl<<endl; break; case 2: cout<<"What is the Radius of circular ends? "; cin>>radius; cout<<"What is the Height of the Cylinder? "; cin>>height; cout<<"The Volume of The Cylinder is "<<cylinder(radius,height); cout<<endl<<endl<<endl; break; case 3: cout<<"What is the Radius of the circle? "; cin>>radius; cout<<"What is the Height of the Cone? "; cin>>height; cout<<"The Volume of The Cone is "<<cone(radius,height); cout<<endl<<endl<<endl; break; case 4: cout<<"What is the length of the base? "; cin>>length; cout<<"What is the Width of the base? "; cin>>width; cout<<"What is the Height of the Pyramid? "; cin>>height; cout<<"The Volume of The Pyramid is "<<pyramid(length,width,height); cout<<endl<<endl<<endl; break; case 5: cout<<"What is the Width? "; cin>>width; cout<<"What is the Length? "; cin>>length; cout<<"What is the Height? "; cin>>height; cout<<"The Volume of The Box is "<<box(width,length,height); cout<<endl<<endl<<endl; break; case 6: default: break; } }while(100); return 0; } double sphere(double radius) { double pi=3.1415926; return 4*(pi*(radius*radius*radius))/3; } double cylinder(double radius, double height) { double pi=3.1415926; return pi*(radius*radius)*height; } double cone(double radius, double height) { double pi=3.1415926; return (((pi*(radius*radius))*height)/3); } double pyramid(double length, double width, double height) { return (length*width*height)/3; } double box(double width, double height, double length) { return (width*height*length); }