CS 13A
Dr. Sturm HW #7 – Structs
(This HW
will not be collected.)
1.
Write a struct definition
for the struct illustrated below:
phone:
|
areaCode |
number |
2.
Write a struct definition
for the struct illustrated below. Member variable homephone
is of type phone defined in part (1) of this question.
employee:
|
name |
homePhone |
age |
hours[7] |
3.
Write a main function that declares an element e of
type employee. Write statements that assign
the values listed below:
Object e is
assigned the phone number: (718)951-3829
Object e has 8 hours assigned to the third element
of the hours array.
4.
Write a void function called getEmployee. Function getEmployee
has one reference parameter emp of type
employee. The function prompts the user
for values and assigns them to the member variables.
5.
Declare a pointer variable p, of type employee. Allocate a struct
of type employee with the new operator (p = new employee). Write statements that assign values to the
members of the newly allocated struct.