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 find the area and circumference of circle , the area and perimeter of rectangle using function overloading

Program in C++ to find the area and circumference of circle , the area and perimeter of rectangle using Function overloading


#include<iostream>
#include<conio.h>
 using namespace std;
 void Area(int ,float &,float &);
 void Area(int ,int,int &,int &);
 int main()
  {
   int r,l,b;
   cout<<"Enter a radius of circle :-";
   cin>>r;
   cout<<"Enter lenght & breadth of rectangle :-";
   cin>>l>>b;
   float a,c;
   //Circle
   Area(r,a,c);
   cout<<"Area of circle="<<a;
   cout<<"\nCircumference of circle="<<c;
   //Rectangle
   int a2,p;
   Area(l,b,a2,p);
   cout<<"\n\nArea of rectangle="<<a2;
   cout<<"\nPerimeter of rectangle="<<p;
   getch();
   }
  void Area(int r1,float &a1,float &c1)
   {
     a1=22.0/7.0*r1*r1;
     c1=2*22.0/7.0*r1;
   }
  void Area(int l1,int b1,int &a1,int &c1)
   {
   a1=l1*b1;
   c1=2*(l1+b1);
   }
Output:-


Post a Comment

0 Comments