#include<iostream.h> #include<conio.h> #define pi 3.14 class vol { int a,l,b,h,r,h1; public: void getdata() { cout<<"enter a value:"; cin>>a; cout<<"enter l b h values is:"; cin>>l>>b>>h; cout<<"enter r h1 values:"; cin>>r>>h1; } void putdata() { cout<<" the voluem of cube is=:"<<cube(a); cout<<" the voluem of rectangle is=:"<<rec(l,b,h); cout<<" the voluem of cylinder is=:"<<cylin(r,h1); } float cube(float x) { return(x*x*x); } float cylin(float x,float y) { return(pi*x*x*y); } float rec(float x,float y,float z) { return(x*y*z); } }; void main() { clrscr(); vol v; v.getdata(); v.putdata(); getch(); }
Sunday, 7 December 2014
C++ program to calculate volume of cube, volume of rectangle and volume of cylinder
Posted by Madan
Posted on 13:55