Lab 16 - City University of New York



Lab 17

Problem 1: Compute the area and perimeter of a circle.

In this program, you need to write two functions:

The first function is named by CalRec, which has no returned value and accepts three parameters: radius, area, and circumference (radius is the parameter passed by value; area and circumference are parameters passes by reference). This function will calculate the area and circumference of the circle as:

area=pi*radius*radius;

And calculate the perimeter of the rectangle as:

perimeter=2*pi(radius;

The second function is named by PrintRec, which has no returned value and accepts two parameters: area and circumference (both are parameters passed by value). This function will print the results as:

The area of the circle is ***.

The circumference of the circle is ***.

In the main function, you prompt user to enter the radius of the circle, and then call the function CalRec to get area and circumference, and then call the function PrintRec to print the results.

Problem 2: Write three functions to convert feet to inches, convert inches to centimeters, and convert centimeters to meters. Write a program that prompts a user for a measurement in feet and converts and outputs this value in meters.

Facts to use: 1 ft = 12 inches, 1 inch = 2.54 cm, 100 cm = 1 meter.

The basic structure for the program is:

#include

using namespace std;

//function declarations(prototypes)

int main()

{

    double feet, inches, cms, meters;

    cout feet;

//call functions and assign the returned value to inches, cms and meters respectively.

    cout ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download