Please I need complete codes in c in this question Implement
Solution
**********************************Program File*******************************************
#include<iostream>
 #include<cmath>
 #include<vector>
 using namespace std;
 //base shape class
 class Shape{
 public:
    //function to return area of the shape
    virtual double getArea() = 0;
 };
//2dshape class inheriting from shape class
 class Shape2D : public Shape {
 public:
    virtual double getArea() = 0; //get area function
       
 };
 //2dshape square inheriting from shape class
 class Square : public Shape2D{
 public:
    double length;
    Square(double ilength){
        length = ilength;
    }
   
    virtual ~Square(){}
    virtual double getArea() { return length * length;}
   
   
   
 };
 //2dshape circle inheriting from shape class
 class Circle:public Shape2D{
 public:
    double r;
    Circle(double radius){
        r=radius;
    }
    virtual ~Circle(){}
        virtual double getArea() { return 3.14 * r*r;}
   
   
 };
 //2dshape Triangle inheriting from shape class
 class Triangle : public Shape2D{
 public:
    double width,height;
    Triangle(double iwidth, double iheight){
        width = iwidth;
        height = iheight;
    }
    virtual ~Triangle(){}
    virtual double getArea() { return (width * height)/2;}
 };
 //3dshape class inheriting from shape class
 class Shape3D : public Shape{
 public:
   
    virtual double GetVolume() = 0;
 };
 //Cube class inheriting from shape class
 class Cube : public Shape3D{
 public:
    Cube(double isideLength){
        sLength = isideLength;
    }
    virtual ~Cube(){}
    virtual double getArea(){return 6*sLength *sLength;}
    virtual double GetVolume(){return sLength*sLength *sLength;}
 private:
    double sLength;
 };
 //Sphere class inheriting from shape class
 class Sphere : public Shape3D{
 public:
    Sphere(double iradius){
        rad = iradius;
    }
    virtual ~Sphere(){}
    virtual double getArea(){return 4 * 3.14 * rad * rad;}
    virtual double GetVolume(){return (4/3)*3.14*rad*rad *rad;}
 private:
    double rad;
 };
 int main(){
    //vector array size of five
    vector <Shape*> array0(5);
   array0[0]= new Square(6);
    array0[1]= new Circle(8);
    array0[2]= new Triangle(6,10);
    array0[3]= new Cube(6);
    array0[4]= new Sphere(8);
   
   
    for(size_t num=0;num<array0.size();num++)
    {
        cout<<\"\ Area: \"<<array0[num]->getArea()<<endl;
        if( Shape3D* pointer3DShape = (dynamic_cast<Shape3D*>(array0[num])) )
        {
            cout<<\"\ Volume: \"<<pointer3DShape->GetVolume()<<endl;
        }
    }
   
    //deleting the shapes in the array to free the memory
    for(size_t i=0; i < array0.size(); i++)
    {
        delete array0[i];
    }
    cin.ignore(100, \'\ \');
    cin.get();
    return 0;
 }
*************************************output***********************************
 Area: 100
Area: 452.16
Area: 75
Area: 216
Volume: 216
Area: 1017.36
Volume: 2289.06




