Answer to Question #180334 in C++ for george

Question #180334

Write a program using constructor overloading to implement the following tasks:


1.Print sides of a cube


2.Print radius and height of the cylinder


3.Calculate the volume of a cube


4.Calculate thevolume of a cylinder



1
Expert's answer
2021-04-11T11:08:23-0400
#include<bits/stdc++.h>
using namespace std;
class dimensions
{
public:
    float len_cube,r,h;
    dimensions(float len_cube)
    {
        float area;
        cout<<"Length of sides of cube are : "<<len_cube;
        area=len_cube*len_cube*len_cube;
        cout<<"\nVolume of cube = "<<area;
    }
    dimensions(float r,float h)
    {
        float area;
        cout<<"Dimensions of cylinder are,\nHeight : "<<h<<"\nRadius : "<<r;
        area=3.14*r*r*h;
        cout<<"\nVolume of cylinder = "<<area;
    }


};

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS