8.4 Programming Exercises

I l @ ve RuBoard

Exercise 8-1: Print a checkerboard (8-by-8 grid). Each square should be 5-by-3 characters wide. A 2-by-2 example follows :

 +-----+-----+                                      +-----+-----+                                      +-----+-----+ 

Exercise 8-2: The total resistance of n resistors in parallel is:

1 / R = 1 / R 1 + 1 / R 2 + 1 / R 3 + ... + 1 / R n

Suppose we have a network of two resistors with the values 400 figs/u03a9.gif and 200 figs/u03a9.gif . Our equation would be:

1 / R = 1 / R 1 + 1 / R 2

Substituting in the value of the resistors we get:

1 / R = 1 / 400 + 1 / 200

1 / R = 3 / 400

R = 400 / 3

So the total resistance of our two-resistor network is 133.3 figs/u03a9.gif .

Write a program to compute the total resistance for any number of parallel resistors.

Exercise 8-3: Write a program to average n numbers .

Exercise 8-4: Write a program to print out the multiplication table.

Exercise 8-5: Write a program that reads a character and prints out whether it is a vowel or a consonant.

Exercise 8-6: Write a program that converts numbers to words. Example: 895 results in "eight nine five."

Exercise 8-7: The number 85 is said "eighty-five," not "eight five." Modify the previous program to handle the numbers 0-100 so all numbers come out as we really say them. For example, 13 is "thirteen," and 100 is "one hundred."

I l @ ve RuBoard


Practical C++ Programming
Practical C Programming, 3rd Edition
ISBN: 1565923065
EAN: 2147483647
Year: 2003
Pages: 364

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net