Programming Exercises

I l @ ve RuBoard

Programming Exercises

  1. Find out what your system does with integer overflow, floating-point overflow, and floating-point underflow by using the experimental approach; that is, write programs having these problems.

  2. Write a program that asks you to enter an ASCII code value, such as 66, and then prints the character having that ASCII code.

  3. Write a program that sounds the alert and then prints the following text:

     Startled by the sudden sound, Sally shouted, "By the Great Pumpkin, what was that!" 
  4. Write a program that reads in a floating-point number and prints it first in decimal-point notation and then in exponential notation. Have the output use the following format:

     The input is 21.290000 or 2.129000e+001. 
  5. There are approximately 3.156 — 10 7 seconds in a year. Write a program that requests your age in years and then displays the equivalent number of seconds.

  6. The mass of a single molecule of water is about 3.0 — 10 - 23 grams. A quart of water is about 950 grams. Write a program that requests an amount of water, in quarts, and displays the number of water molecules in that amount.

I l @ ve RuBoard


C++ Primer Plus
C Primer Plus (5th Edition)
ISBN: 0672326965
EAN: 2147483647
Year: 2000
Pages: 314
Authors: Stephen Prata

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