Thursday, October 16, 2014

program to find area of circle making getdata() function as a private function in C++



Prog 22:Write a program to find area of circle making getdata()
function as a private function.

include <iostream.h>
include <conio.h>
class circle
{


int a,r;
public:
void getdata();
void area();
};


void circle::getdata()
{
cout<<"\nenter r";
cin>>r;
}
void circle::area()
{
getdata();
a=3.14*r*r;
cout<<"\n area is"<<a;
}
void main()
{
clrscr();
circle c;
c.area();
getch();
}

Output:

enter r
10
area is314

No comments: