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 05: If intro

Name: _____________________________________________ Alpha: ___________________

Describe help received: ________________________________________________________

  • Due before class on Monday, January 23
  • This homework contains code to be submitted electronically. Put your code in a folder called hw05 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 (Expressions and Statements) and 6 (Branching) from the Unit 2 notes.
  2. Write a program in a file called sleeping.c that reads a 4-digit time (HHMM, 24-hour time), and prints out "Awake" if the time is between 0600 and 2300 (inclusive), and "Asleep" otherwise.

    Example of running your program:

    roche@ubuntu$ ./sleeping
    Time: 0330
    Asleep
    roche@ubuntu$ ./sleeping
    Time: 1650
    Awake
    roche@ubuntu$ ./sleeping
    Time: 2301
    Asleep