Lab 5 -- C++ Simple Data Types, Structs and Array of Structs

Answer Sheet

Exercise 1

Determine how the following variables should be declared in order to maintain good memory usage by the compiler.

a) the number of students in a class

b) the distance to the moon

c) last month's checking account balance

d) a counter used to count the number of lines in a text file

e) number of people living in the US

f) the temperature used in a chemistry formula

Exercise 2

a) Show how to declare Real as a synonym for float (float and Real can be used interchangeably).

b) Show how to declare the following constants using an enum statement: WINTER =0, SPRING = 1, SUMMER = 2 and FALL = 3.

Exercise 3

{ Script }

Exercise 4

{ Script }

Exercise 5

{ Script }

Exercise 6

{ Script }

Exercise 7

Write code to print out the id number of the second customer included in the allCustomers array as described in exercise 6.

Exercise 8

{ Script }

Exercise 9

{ Script }

Exercise 10

{ Script }

----- End of Lab 5 - C++ Simple Data Types, Structs and Array of Structs -----
Complete the Exercises on the Answer Sheet.
Turn in the Answer Sheet and the printouts required by the exercises.