Programming Exercises
-
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.
-
Write a program that asks you to enter an ASCII code value, such as 66, and then prints the character having that ASCII code.
-
Write a program that sounds an alert and then prints the following text:
-
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):
-
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.
-
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.
-
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.
Startled by the sudden sound, Sally shouted, "By the Great Pumpkin, what was that!"
The input is 21.290000 or 2.129000e+001.