Write a program to calculate the area of circle, rectangle and square using class & object.
CODING:
#include<iostream.h>
#include<conio.h>
class math
{
int a,b;
public:
void rinput(void);
void routput(void);
void recinput(void);
void recoutput(void);
void sqinput(void);
void sqoutput(void);
};
void math::rinput(void)
{
cout<<"Enter Radius of Circle:";
cin>>a;
}
void math::routput(void)
{
cout<<"Area of Circle is:"<<3.14*a*a;
}
void math::recinput(void)
{
cout<<"\nEnter Length of Rectangle:";
cin>>a;
cout<<"Enter Breadth of Rectangle:";
cin>>b;
}
void math::recoutput(void)
{
cout<<"Area of Rectangle is:"<<a*b;
}
void math::sqinput(void)
{
cout<<"\nEnter side of Square:";
cin>>a;
}
void math::sqoutput(void)
{
cout<<"Area of Square is:"<<a*a;
}
void main()
{
clrscr();
math obj;
obj.rinput();
obj.routput();
obj.recinput();
obj.recoutput();
obj.sqinput();
obj.sqoutput();
getch();
}
CODING:
#include<iostream.h>
#include<conio.h>
class math
{
int a,b;
public:
void rinput(void);
void routput(void);
void recinput(void);
void recoutput(void);
void sqinput(void);
void sqoutput(void);
};
void math::rinput(void)
{
cout<<"Enter Radius of Circle:";
cin>>a;
}
void math::routput(void)
{
cout<<"Area of Circle is:"<<3.14*a*a;
}
void math::recinput(void)
{
cout<<"\nEnter Length of Rectangle:";
cin>>a;
cout<<"Enter Breadth of Rectangle:";
cin>>b;
}
void math::recoutput(void)
{
cout<<"Area of Rectangle is:"<<a*b;
}
void math::sqinput(void)
{
cout<<"\nEnter side of Square:";
cin>>a;
}
void math::sqoutput(void)
{
cout<<"Area of Square is:"<<a*a;
}
void main()
{
clrscr();
math obj;
obj.rinput();
obj.routput();
obj.recinput();
obj.recoutput();
obj.sqinput();
obj.sqoutput();
getch();
}
Comments
Post a Comment