Listing 1 shows ABCD.cpp program to compute diameter, circumference and area for a circle with r, radius without user-defined function. Listing 2 shows the expected output of ABCD.cpp on the screen after creating user-defined functions for 3 circles of radius. Write a complete code to compute an output of 3 circles with r, radius as shown in Listing 2. Your answer should have four (4) functions as stated below as function declaration.
double displayRadius(double);
double displayDiameter(double);
double displayCircumference(double);
double displayArea(double);
source code:
#include
<iostream>
using namespace std;
double
displayRadius()
{
double r;
cout<<"Enter radius : ";
cin>>r;
return r;
}
double
displayDiameter(double r)
{ //implementing functions
return r+r;
}
double
DisplayCircumference(double r)
{
return 2*3.14*r;
}
double displayArea(double
r)
{
return 3.14*r*r;
}
int main()
{
double r=displayRadius(); //calling functions
cout<<"radius is : "<<r;
cout<<"\nDiameter of circle is :
"<<displayDiameter(r);
cout<<"\ncicu,ference of circle is :
"<<DisplayCircumference(r);
cout<<"\nArea of circle is
:"<<displayArea(r);
return 0;
}
if you have any doubts ask me
Get Answers For Free
Most questions answered within 1 hours.