Write a program in C++ to find the volume using function overloading
#include<iostream.h>
int volume(int); float volume(int,int); int volume(int,int,int); void main() { int x,z,l,b,r,h; float y; cout << "enter the values of l,b,h,r"<<endl; cin >> l>> b>>h >>r; x=volume(l); y=volume(r,h); z=volume(l,b,h); cout << "volume of cube is : "<<x<<endl; cout << "volume of cylinder is : "<<y<<endl; cout << "volume of rectangle is : "<<z<<endl; } int volume(int a) { return (a*a*a); } float volume(int a,int b) { return (3.14*a*a*b); } int volume(int a,int b,int c) { return (a*b*c); } |