Page 1 of 1

Write a program to create a base class named “circle”. Derive another class “cylinder” from it. The program should calcu

Posted: Mon Jun 06, 2022 12:40 pm
by answerhappygod
Write a program to create a base class named “circle”. Derive
another class “cylinder” from it. The program should calculate
total surface area of circle and cylinder using the concept of
inheritance. Circle should have data fields i.e. radius, area and
method getRadius ( ) should take value of radius from user.
Cylinder should have additional data field i.e. height and
additional method getHeight ( ) to assign value of height.
Similarly, area ( ) function calculates area and display ( )
function prints the final area of the created objects i.e circle
and cylinder. (Circle surface area=pi*r*r and cylinder surface
area=2*pi*r*r+2*r*h)