CST 180: Structured Data Worksheet



CST 180: Structured Data Worksheet Name:______________________________

1. Write a structure declaration to hold the following data about a savings account:

Account Number (15 character string)

Account Balance (double)

Interest Rate (double)

Average Monthly Balance (double)

2. Write a definition statement for a variable of the structure you declared in question 1. Initialize the members with the following data:

Account Number: ACZ42137-B12-7

Account Balance: $4512.59

Interest Rate: 4%

Average Monthly Balance: $4217.07

For questions 3 through 6 below, assume the Product structure is declared as follows:

struct Product

{

char description[50]; // Product description

int partNum; // Part Number

double cost; // Product cost

};

3. Write a definition for an array of 100 Product structures. Do not initialize the array.

4. Write a loop that will step through the entire array you defined in question 3, setting all the product descriptions to a null string, all part numbers to zero, and all costs to zero.

5. Write the statements that will store the following data in the first element of the array you defined in Question 3.

Description: Claw Hammer

Part Number: 547

Part Cost: $8.29

6. Write a loop that will display the contents of the entire array you created in Question 3.

7. Is it possible for a structure variable to be a member of another structure variable? Yes__________ No___________

8. Can structure variables be passed as arguments to functions?

Yes__________ No___________

9. Can a function return a structure?

Yes__________ No___________

10. If you wanted to modify a structure inside a function, which would you use?

Pass By Value_____________ Pass by Reference_________________

11. How should handle passing large structures to a function? Why?_____________

________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________

................
................

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

Google Online Preview   Download