Program for area of a circle using class in C++
Program for area of a circle using class:
#include<iostream>
using namespace std;
class circle
{
float r;
float area;
public:
void getdata()
{
cout<<"Enter the value: "<<endl;
cin>>r;
}
void showdata()
{
area=3.14*r*r;
cout<<"Area is: "<<area;
}
};
int main()
{
circle c;
c.getdata();
c.showdata();
}
output:
Enter the value:
4
Area is: 50.24
Comments
Post a Comment