Question: In this exercise, you will modify the program from Lab10-1. Modify the program to allow the user to display a circle's circumference, given its radius.

In this exercise, you will modify the program from Lab10-1. Modify the program to allow the user to display a circle's circumference, given its radius. Use a void function named getCircumference. Test the program appropriately.

Lab10-1

#include

#include

using namespace std;

//fuction prototypes

void displayChoices( );

void getArena (double rad, double &area);

void getDiameter (double rad, double &diameter);

int main ( )

{

int choice = 0;

double radius = 0.0;

double circleArea = 0.0;

double circleDiameter = 0.0;

displayChoices( );

cout << "Enter your choice (1 or 2): ";

cin >> choice;

if (choice < 1 || choice > 2)

cout << "Invalid choice" << end1;

else

{

cout << "Radius: ";

cin >> radius;

if (choice == 1)

{

getArea (radius, circleArea);

cout << "Area: " << circleArea;

}

else

{

getDiameter(radius, circleDiameter);

cout << "Diameter: " << circleDiameter;

} // end if

cout << end1;

} // end if

return 0;

} // end of main function

// ****function definitions****

void displayChoices ( )

{

cout << "1 Circle area" << end1;

cout << "2 Circle diameter" << end1;

}

void getArea (double rad, double &area)

{

const double PI = 3.141593;

area = PI * pow(rad, 2);

} // end getArea function

void getDiameter (double rad, double &diameter)

{

diameter = 2 * rad;

} // end getDiameter function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!