Home >> Sem 2 >> C++ programs >> DEFAULT1
/* Write a program to implement default argument as a function to find
out the area of the circle */
#include<iostream.h>
#include<conio.h>
class shape
{
int a;
float p;
public:
void getdata(int, float pi=3.14);
void show()
{
float ans;
ans = a * (p * p);
cout<<"Area of the circle : "<<ans;
}
};
void shape::getdata(int n,float pi)
{
p = pi;
a = n;
}
void main()
{
int a;
shape circle;
clrscr();
cout<<"Enter the value of Radius : ";
cin>>a;
circle.getdata(a);
circle.show();
getch();
}