SI 204 Spring 2017 / HWs


This is the archived website of SI 204 from the Spring 2017 semester. Feel free to browse around; you may also find more recent offerings at my teaching page.

Homework 30: Struct composition

Name: _____________________________________________ Alpha: ___________________

Describe help received: ________________________________________________________

  • Due before class on Monday, April 10
  • This homework contains code to be submitted electronically. Put your code in a folder called hw30 and submit using the 204sub command.
  • This is an electronic homework and you do not need to print out anything to turn in during class.

Assignment

  1. Required reading: Sections 5 (Sorting structs) and 6 (composition of structs) from the Unit 8 notes.
  2. First download the partially-complete program bdays.c from this link. This is a program to read in people's names and birthdays and then print them out in order from youngest to oldest. Most of the program has been written for you, including two struct definitions, two useful functions, and the main function. All you should change is to fill in the definitions of functions before and write_person.

    Example runs:

    roche@ubuntu$ ./bdays
    How many people? 3
    Bob 7/28/1991
    Lisa 2/13/1988
    Mary 1/1/2003
    
    From youngest to oldest:
    Mary 1/1/2003
    Bob 7/28/1991
    Lisa 2/13/1988
    roche@ubuntu$ ./bdays
    How many people? 4
    Susan 6/13/1993
    Elijah 6/18/1993
    Anne 2/18/1993
    Cecil 8/3/1992
    
    From youngest to oldest:
    Elijah 6/18/1993
    Susan 6/13/1993
    Anne 2/18/1993
    Cecil 8/3/1992