adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Program in C++ to Calculate area and perimeter of the rectangle Using Class

Program in C++ to Calculate area and perimeter of the rectangle Using Class


#include<iostream>
#include<conio.h>
 using namespace std;
 class Rectangle
 {
  private:
     float length,breadth;
    public:
   void input()
    {
       cout<<" Enter length and breadth of Rectangle:-";
       cin>>length>>breadth;
    }
      void Area()
       {
          float a=length*breadth;
          cout<<" Area of Rectangle ="<<a;
       }
       void Perimeter()
        {
          float p=2*(length+breadth);
          cout<<"\n Perimeter of Rectangle ="<<p;
 }
 };
   
   int main()
    {
        Rectangle c1,c2;
        c1.input();
        c1.Area();
        c1.Perimeter();
        return 0;
    }
Output:-





Post a Comment

0 Comments