HSC Science (Computer Science) 12th Board ExamMaharashtra State Board
Share
Notifications

View all notifications

Write a Program in C++ to Find Area of Circle Using Class. - HSC Science (Computer Science) 12th Board Exam - Computer Science 1

Login
Create free account


      Forgot password?

Question

Write a program in C++ to find area of circle using class.

Solution

#include
#include
class shape
{
  public:double x,y;
  virtual void getdata()=0;
  virtual void area()=0;
};

class circle : public shape
{
  public:double are;
  int aa;
  void getdata()
  {
    cout<<"\nenter the radius";
    cin>>aa;
  }
  void area()
  {
    are=(3.14 *aa*aa);
  }
  void display()
  {
    cout<<"area of circle is"<<  are;
  }
};

int main()
{
  shape *s;
  circle c;
  clrscr();

  cout<<"\n\n CIRCLE ..........\n\n";
  s=&c;
  s->getdata();
  s->area();
  c.display();

  getch();
  return 0;
}
  Is there an error in this question or solution?

APPEARS IN

 2014-2015 (March) (with solutions)
Question 5.2.2 | 5.00 marks
Solution Write a Program in C++ to Find Area of Circle Using Class. Concept: C++ Programming.
S
View in app×