saving . . . saved inheritance has been deleted. inheritance has been hidden .
inheritance
Title
Question
<span style="color: rgb(51, 51, 51); font-family: Arial; font-size: 12.6px; white-space-collapse: preserve; background-color: rgb(249, 249, 249);">Create a class Shape. Create two functions of the class as Area and Perimeter. Find the area and perimeter of various shapes like square, rectangle and circle.</span>

Advanced-Cpp Inheritance 08-09 min 10-20 sec 23-11-23, 7:19 p.m. ANushika_321

Answers:

Please specify the difficulty you are facing
18-01-24, 3:57 p.m. chitra@devi
Jsh
16-03-24, 11:01 p.m. garanjith4257@gmail.com
Yes
18-04-24, 7:27 p.m. srcw2326j132@srcw.ac.in

Login to add comment


Sir I am preparing for exam
25-01-24, 1:50 p.m. ajaykumar752007@gmail.com
Please specify the difficult you are facing 
16-03-24, 11:02 p.m. garanjith4257@gmail.com

Login to add comment



#include <iostream>
using namespace std;

class Shape {
public:
    void Area(double side) {
        cout << "Square Area: " << side * side << endl;
    }

    void Area(double length, double width) {
        cout << "Rectangle Area: " << length * width << endl;
    }

    void AreaCircle(double radius) {
        cout << "Circle Area: " << 3.14 * radius * radius << endl;
    }

    void Perimeter(double side) {
        cout << "Square Perimeter: " << 4 * side << endl;
    }

    void Perimeter(double length, double width) {
        cout << "Rectangle Perimeter: " << 2 * (length + width) << endl;
    }

    void PerimeterCircle(double radius) {
        cout << "Circle Perimeter: " << 2 * 3.14 * radius << endl;
    }
};

int main() {
    Shape s;

    s.Area(5); // Square
    s.Perimeter(5);

    s.Area(4, 6); // Rectangle
    s.Perimeter(4, 6);

    s.AreaCircle(3); // Circle
    s.PerimeterCircle(3);

    return 0;
}
14-07-25, 12:33 p.m. 240181601063@crescent.education


Log-in to answer to this question.