Write a program class circle that calculate and display circumference of circle.
#include
<iostream>
#include
<conio>
#Include
<stdlib>
class circle
{
public:
float a,c,r;
public:
void
setradius(r)
{
cout<<endl<<endl;
cout<<" Set Radius "<<endl;
cout<<endl<<endl;
cout<<"\t\t\t\t"<<r<<endl;
}
void area(r)
{
a=3.14*r*r;
cout<<endl<<endl;
cout<<" Area of The Circle is :\t\t"<<a<<endl;
}
void circum(r)
{
c=2*3.14*r;
cout<<endl<<endl;
cout<<" Circumference Of The Circle is
:\t\t"<<c<<endl;
} };
void main()
{
circle cr; //object of class
int b;
cout<<endl<<endl;
cout<<" Get Radius "<<endl;
cout<<endl<<endl;
cout<<" Enter The Radius :\t\t";
cin>>b;
cr.setradius(b); //function call of setradius
cr.area(b); //function call of area
cr.circum(b); //function call of circumference
getch();
}
OUT PUT:
C++ Area and Circumference of Circle |
Post a Comment