LAB 07B - PRACTICE SRUCTS
Concepts
The goal of this lab is to continue gaining practice with struct
s.
Instructions
To begin, create an empty project (however fits your fancy!). Then complete the following five TO DO items.
- TO DO #1:
Define a globalstruct
calledMeasurement
with the following two data members:-
miles
, an integer variable -
meters
, a long integer variable
-
- TO DO #2:
Define a globalstruct
calledDestination
with the following two data members:-
city
, a string variable -
distance
, aMeasurement
variable
-
- TO DO #3:
First, declare a variable of typeDestination
inmain.cpp
. Second, use assignment statements to set the following values:-
city
: Tupelo -
miles
: 375 -
meters
: 603,375
-
- TO DO #4:
Write a function calledPrintDest
that has oneDestination
parameter (passed by reference, but not allowed to change) and no return value. This function should then print out the city and the distance in miles and meters. Add the function prototype above yourmain.cpp
and the function definition below yourmain.cpp
.
- TO DO #5:
In yourmain.cpp
, call the functionPrintDest
with theDestination
variable declared in TO DO #3.
As always, we recommend an incremental build strategy. Once TO DO #1 is completed and tested, get TO DO #2 working properly. Once TO DO #2 is completed and tested, move on. And so forth.
This Lab will be due with Homework 07.