My photo
Bangalore, Karnataka, India
Extending one hand to help someone has more value rather than joining two hands for prayer

Archives

program to find the area and circumference of circle using classes

Tuesday, September 1, 2009

#include<iostream.h>
#include<conio.h>
class circle
{
 float r;
 public:
 void setdata();
 void area();
 void circum();
 };
 void circle::setdata()
 {cout<<"enter the radius of circle  ";
  cin>>r;
 }
 void circle::area()
 {  double area;
    area=3.14*r*r;
    cout<<"area of circle "<<area<<endl;
  }
 void circle::circum()
 {  double cir;
    cir=2*3.14*r;
    cout<<"circumference of circle is "<<cir<<endl;
  }
  void main()
  { clrscr();
   circle c1,c2;
    c1.setdata();
    cout<<"for first circle"<<endl;
    c1.area();
    c1.circum();
    cout<<"for second circle"<<endl;
    c2.setdata();
    c2.area();
    c2.circum();
    getch();
    }

0 comments: