CSE110 Spring 2001

Homework #1

Due Friday, February 2nd at 5pm

Note: bold text in the examples is input from the user.


  1. [25 points] Write a C program that prints your name, followed by a dash, followed by your favorite kind of puppet (e.g. hand puppet, finger puppet, sock puppet, dummy, muppet, marionette). Grading will not depend on choice of puppet.

    Example: If you were George W. Bush, your program would print:

    % a.out
    George W. Bush - muppet
    
  2. [30 points] Seeing as how you like puppets so much, write a C program that calculates the age of your puppet collection, to help you evaluate it as an investment. Your program should:

    Example:

    % a.out
    My antique puppet collection is 20 years old.
    
  3. [30 points] There's trouble at the puppet factory -- it's been seized by pirates who insist you help them divvy up the booty. Write a C program that prompts the user for two integers (one for the number of puppets and one for the number of pirates) and prints out the number of puppets per pirate in the following form, or you'll surely walk the plank: "X puppets divided by Y pirates means each pirate gets Z puppets, and the captain gets the R left over," where X is the number of puppets, Y is the number of pirates, Z is the result of the division, and R is the (modulo) remainder.

    Example:

    % a.out
    How many puppets have ye me hardies?
    50
    And what number of pirates there be?
    12
    50 puppets divided by 12 pirates means each pirate gets 4 puppets, 
    and the captain gets the 2 left over.
    
  4. Recall that given two integer arguments, the "/" operator yields the quotient of the two numbers and the "%" operator yields the remainder.