Homework Assignments – Spring 2010
C Programming (COP-2220)

Assignments, due dates, and hints are given below, most recent
first. Homework is due by midnight of the date shown. Send
your homework as an email attachment from your FSCJ email account
to sdifranc@fscj.edu.
Include your name, homework number, and the class and reference
number in the subject line as described in the
homework guidelines.
Note: If you are asking for help on an assignment rather
than turning it in, make sure to include the word "Help" in
the subject line.
Hw07: Converting Temperatures (due 3/10)
Write a program to convert a temperature input in Celsius or
Fahrenheit to the other scale. Provide an appropriate prompt,
and accept the temperature input as a double, followed by
a char representing the scale (C or F). Make sure the
temperature entered is not less than absolute zero. (Display an
error message if this is the case.) Perform the appropriate
conversion and display the original input and result, both
rounded to one decimal place, as in this
sample executable. Continue prompting the user for a
temperature and scale to convert until the user enters EOF.
The conversion formulas are as follows, where C is a
temperature in degrees Celsius, and F the equivalent in
Fahrenheit:
C = (5.0 / 9.0) * (F - 32)
F = ((9.0 / 5.0) * C) + 32
This is a team assignment. Here are the teams:
- Tony A. (allet8) & Joseph W. (wisnjj1)
- Howard C. (carahw) & Jared C. (campjr6)
- Bryan E. (ellibs1) & Brooks C. (comeb)
- Corey F. (fishcs2) & Kenny F. (feieka1) & Jason V. (voorjb)
- Chris F. (fulgc) & Hector F. (florhl)
- Megan H. (hailmj) & Titngai T. (tamt)
- Alex M. (moyeam) & Mansel K. (karam2)
- Owen P. (philok) & Daniel G. (grahd)
- Zach P. (privza) & Daniel O. (orlada)
- Edward S. (swine) & Lovander P. (powel9)
- Teddy T. (turntt) & Derek Y. (youndd3)
- Madalene V. (voormn) & Pratyusha S. (somapv1)
Submit your assignment as hw07-xxx.c,
where xxx are the initials of the
team member turning it in. Don't forget to cc the other team
member(s).
Hw06: Equivalent Resistance (due 3/3)
The formula for the total resistance rt of
a circuit with n parallel resistors is:

Write a program to allow the user to input an arbitrary
number of floating point resistances r1, r2
, ... in ohms, terminating when the user 0 (or EOF, or
any invalid input), then display the equivalent resistance in
ohms, rounded to three decimal places. Here is an example:
presist2.exe
Hw05: Quadratic Formula (due 2/24)
From algebra, you remember that
the general solution (the roots) to the quadratic equation of
the form

can be obtained
as:

Write a program that prompts the user for three floating
point values representing the coefficients a, b,
and c of a quadratic equation, inputs them (using
scanf),
then calculates and displays the roots of the equation. Here is
an example, compiled program:
quad.exe Note
that you should verify that a is not equal to 0. Also, there may
be no roots, one root, or two roots, depending on whether the
discriminant (b2 –
4ac) is negative, zero, or positive, respectively. You
will need to use the sqrt function
from the math.h header
file.
For an extra challenge, write the
program so that the user can enter a succession of coefficients,
terminating input by enter EOF (Ctrl + Z), as in this program:
quad_2.exe.
This is a team assignment. Please read the
guidelines for team
assignments. Here are the teams:
- Tony A. (allet8) & Jared C. (campjr6)
- Howard C. (carahw) & Brooks C. (comeb)
- Bryan E. (ellibs1) & Kenny F. (feieka1)
- Corey F. (fishcs2) & Hector F. (florhl)
- Chris F. (fulgc) & Daniel G. (grahd)
- Megan H. (hailmj) & Mansel K. (karam2)
- Alex M. (moyeam) & Daniel O. (orlada)
- Owen P. (philok) & Lovander P. (powel9)
- Zach P. (privza) & Pratyusha S. (somapv1)
- Edward S. (swine) & Titngai T. (tamt)
- Teddy T. (turntt) & Jason V. (voorjb)
- Madalene V. (voormn) & Joseph W. (wisnjj1) & Derek Y.
(youndd3)
Submit your assignment as hw05-xxx.c,
where xxx are the initials of the
team member turning it in. Don't forget to cc the other team
member(s).
Hw04: More Complicated Computations (due 2/17)
Write a program to validate a 16-digit credit/ATM number
using the Codabar system, which catches most numbers containing
incorrect or adjacent transposed digits:
| Double the sum of the odd digits (starting with 1 on
the left) plus the sum of the even digits, plus the
number of the odd digits that are at least 5 must yield
a number ending in 0. |
For example, consider the number 6040 9560 0083
1083. The sum of the odd digits is 6+4+9+6+0+8+1+8 = 42, the sum
of the even digits is 0+0+5+0+0+3+0+3 = 11, and the number of
odd digits >= 5 is 5 (6, 9, 6, 8, 8). And (2 * 42) + 11 + 5 =
100, a number ending in 0, so the card number is valid (at least
in format).
Here is a sample executable you can use to see
the interface and to check your program. Note that the program
will accept spaces or other characters to separate digits or
groups of digits, but also verifies that 16 digits (0-9) have
been entered: ccval.exe
Hw03: Basic Computations (due 2/3)
One of the consequences of the Special Theory of Relativity
is that a moving clock slows down with respect to a stationary
one. At normal velocities this effect is negligible, but at
velocities approaching the speed of light (usually written as
c, which is 300,000 km/sec), the effect is quite pronounced.
This formula shows the time in hours elapsed on a stationary
clock (t) for one hour on a clock moving at velocity v:

Write a program that displays a table of
this "time dilation" effect for velocities 0.1c -0.9c, in
increments of 0.1, as in this sample executable:
timedil.exe
Note you will need to use the
math.h standard library for the
sqrt function.
Save your source code with the filename
hw03-xxx, where xxx
are your initials.
Hw02: Data Representation (due 1/27)
Answer the "Self-test Questions" at the end of the
lecture notes on "Data Representation". Type your answers
with a text editor (like Notepad, but not a word processor, like
WordPad or MS Word), and save it as an ASCII text file with the
name hw02-xxx.txt, where
xxx are your initials.
Hw01: Using The Dev-C++ IDE
(due 1/20)
Modify the program given in the
Dev-C++ Tutorial to prompt the user for a number of students
who have signed up for the senior class trip to Washington,
D.C., then calculate the number of full buses (each can hold 42
students) needed, and the number of students that will be on the
last partially-filled bus (i.e., the number of students
"left over"), if any, and display the result.
As an extra challenge (not extra credit), solve this problem
instead: prompt the user to enter a number of seconds, and
convert this to hours, minutes, and seconds, as in
this program. (This is an executable,
machine language program.)
Save your source code with the filename
Hw01-xxx, where xxx are your
initials, and email to me as an attachment from your student
email account as described in the
homework guidelines.
|