C++ program to demonstrate Default Argument for AreaOfCircle()
#include <iostream>
using namespace std;
float AreaOfCircle(float,float=3.14);
int main()
{
cout<<"Area of circle: "<<AreaOfCircle(7,3.1416)<<endl;
cout<<"Area of circle: "<<AreaOfCircle(7);
return 0;
}
float AreaOfCircle(float r, float pi)
{
return pi*r*r;
}
No comments:
Post a Comment