next up previous
Next: About this document ...

Milestone #5
CpSc 481/681: Skills for Visual Computing
School of Computing
Clemson University
Solving Problems with C
Assignment, If and While
Brian Malloy, PhD
November 6, 2009



The purpose of this milestone is to help you to become familiar with the C language, with programming language constructs and with the logic needed to solve problems using a programming language Your assignment is to use the C language to solve the problems listed below.

  1. Getting off the ground: ``Big Timmy'' is a 5th grader and wants to use the see-saw on the playground. But, there is no kid that weighs enough to get him off the ground! So a group of 1st graders decided they would team up and give it a shot. Assuming each of the 1st graders weighs 30 pounds, how many would have to pile on the other end of the see-saw to move "Big Timmy"? To solve the problem, ask the user to input Timmy's weight, then compute how many 30 pound 1st graders will be needed to balance Timmy.

  2. The Building Boats Problem: A rival tribe has somewhere between 50 and 150 boats. You have none. Even though you don't need boats, your pride won't let a rival tribe have more than you. Luckily, they are only making 1 boat per day, while your people can make 4 boats per day. Input the number of boats the rival tribe currently has, then calculate how many days it will take for your tribe to have at least as many as the rival tribe.

  3. The Factors of a number: Write a program that will request that the user input a number, and then your program will print the factors of that number. For example, if the user inputs the number , your program should output 1, 3, 6, 9, and 18.

  4. The Bartender Problem: Are you tired of looking at ID's? Do you wish there was a way to easily determine someone's age without looking at a cumbersome calendar? Well, with the invention of the C Programming Language and the while loop, it has never been easier. All you have to do is input the year the person says they were born and magically this handy dandy computational device will perform mega ultra complicated calculatory functions and determine if the person is over 21. BUT WAIT, there's more! If you don't believe them ...the trusty dusty while loop will re-ask for the real birth date until the truth comes out. Once it determines the person is not 21 it will promptly print out their proper age and dutifully ask the person to vacate the premises. Normally this program sells for billions of dollars, but for today only, we are giving it away for free. Simply ask any student in CpSc 481/681, and they will provide this program free.

  5. The Power of Two: An Arabian chieftan called upon a neighboring chieftan to help him in a feud. The neighboring chief agreed, provided that the feuding chieftan to pay him in pennies as follows: place one penny the first day, two pennies the second day, four pennies the third day, and so forth, doubling the pennies each day. How much money did the feuding chief have to pay the neighboring chief? Your program should prompt the user to input the number of days. Then your program should use the values in limits.h to determine if you can compute the amount of money that the chief has to pay. If you can compute the amount, compute it and print the sum. Otherwise, print an appropriate message.

  6. Guess the Number: Write a program that will pick a random number from 1 to 100 and then ask the user to guess the number. When the user inputs a guess, tell the user if the guess is too high or too low. Count the number of trials required by the user to guess the number.

  7. Primes: Write a program that will find and print the prime numbers from 1 to 200.

Your assignment must be submitted, using the handin command, by 8 AM on Wednesday, November 11th, 2009. Please compress the directory that contains your C programs and include a readme that contains your name, the course number, and an explanation of the submissions and the filenames. The syntax of the zip and tar commands is:

        zip -r <dir>.zip <dir>
        tar -zcvf <dir>.tar.gz <dir>

And the syntax for the handin command is:

        handin.481.1 5 <compressed directory name>

Where handin.481.1 means that you are using the handin command for CpSc 481, Section 1. The means that this is the second milestone and compressed directory name is the name of the directory that you compressed using either zip or tar.

Good luck with the assignment, and I hope that this milestone helps you to become more comfortable with the C Programming Language.




next up previous
Next: About this document ...
Brian Malloy 2009-11-06