Explanation
The area enclosed
by a circle is π multiplied by the radius squared
Area = π*r*r
Perimeter of circle
C= 2πr
#include<iostream.h>
#include<conio.h>
Class circle
{
Float r;
Float
area,peri;
Public:
Circle()
{
r=10;
}
Circle(int
a)
{
r=a;
}
Void
calc()
{
Area=3.14*r*r;
Peri=2*3.14*r;
}
Void display()
{
Cout<<”\n
area of cricle :”<<area;
Cout<<”\n
Perimeter of circle :”<<peri;
}
~circle()
{
Delete
r;
Delete
area;
Delete
peri;
}
};
Void main()
{
Circle c;
Cout<<’\n
Constructors Without Parameters ;”;
c.calc();
c.display();
Circle
c2(6.5);
Cout<<”\n
Constructors with parameters :”;
C2.calc();
C2.display();
}
No comments:
Post a Comment