Home > Articles > Programming

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

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 an alert and then prints the following text:

  4. Startled by the sudden sound, Sally shouted, "By the Great Pumpkin, what was that!"
  5. 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 actual number of digits displayed for the exponent depends on the system):

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

  8. The mass of a single molecule of water is about 3.0x10-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.

  9. There are 2.54 centimeters to the inch. Write a program that asks you to enter your height in inches and then displays your height in centimeters. Or, if you prefer, ask for the height in centimeters and convert that to inches.

  • + Share This
  • 🔖 Save To Your Account