OOPC Practical 8


Practical : 8
Subject : Object Oriented Programming with C++

Aim :  C++ program calculate the area of circle, rectangle and square using function overloading


Source Code :
#include<iostream.h>
#include<conio.h>
class pratik
{
public:
area(int a)
{
int x=a*a;
cout<<"\n length is : "<<a;
cout<<"\n area of squre is : "<<x<<endl;
}
area(int b,int c)
{
int y=b*c;
cout<<"\n length is : "<<b<<"\n width is : "<<c;
cout<<"\n area of rectangle is : "<<y<<endl;
}
area(double r)
{
double z=3.14*r*r;
cout<<"\n redious is : "<<r;
cout<<"\n area of circle is : "<<z<<endl;
}
};
void main()
{
clrscr();
pratik a,b;
a.area(20,4);
a.area(5);
a.area(5.55);
getch();
}

Output :
function overloading


Pratik Boghani

Author & Editor

Life is all about the next step.

0 comments:

Post a Comment