Write a program to calculate the area of circle, rectangle and square using function overloading.
CODING:
#include<iostream.h>
#include<conio.h>
void area(int);
void area(int,int);
void areaa(int);
void main()
{
int r,l,b,s;
clrscr();
cout<<"Enter Radius of Cirle:";
cin>>r;
area(r);
cout<<"\n\nEnter Length of Rectangle:";
cin>>l;
cout<<"Enter Breadth of Rectangle:";
cin>>b;
area(l,b);
cout<<"\n\nEnter side of Square:";
cin>>s;
areaa(s);
getch();
}
void area(int a)
{
cout<<"Area of Circle is:" <<3.14*a*a;
}
void area(int a,int b)
{
cout<<"Area of Rectangle is:"<<a*b;
}
void areaa(int a)
{
cout<<"Area of Square is:"<<a*a;
}
CODING:
#include<iostream.h>
#include<conio.h>
void area(int);
void area(int,int);
void areaa(int);
void main()
{
int r,l,b,s;
clrscr();
cout<<"Enter Radius of Cirle:";
cin>>r;
area(r);
cout<<"\n\nEnter Length of Rectangle:";
cin>>l;
cout<<"Enter Breadth of Rectangle:";
cin>>b;
area(l,b);
cout<<"\n\nEnter side of Square:";
cin>>s;
areaa(s);
getch();
}
void area(int a)
{
cout<<"Area of Circle is:" <<3.14*a*a;
}
void area(int a,int b)
{
cout<<"Area of Rectangle is:"<<a*b;
}
void areaa(int a)
{
cout<<"Area of Square is:"<<a*a;
}
Comments
Post a Comment