Chapter 3: Programming ExercisesΒΆ

1. Write a small program that will prompt for the input of a value for each of the following types:

 %c - Yes or No
 %s - Your Name
 %d - Your Height
 %ld - The Circumference of the Earth
 %f - Your Bank Balance
 %lf - The Distance from the Earth to the Moon

Read the values with  **scanf()** and then print those
values out on the display using  **printf()**. Then
rewrite the program using  **cin** and  **cout**.

2. Write a program that will prompt for the input of a
temperature in Fahrenheit and will display as output
both the Fahrenheit value and the temperature converted to
Celsius. Use the formula

 Celsius Degrees = (Fahrenheit Degrees - 32) * 5/9

3. Write a program that uses  **scanf()** and  **printf()** statements to prompt for your first name, last name, street, city, state and zip code. After input of the values, then print the values out with the following format:

 City: State:

Rewrite this program using  **cin** and  **cout**.

Previous topic

Chapter 3 Basic Input-Output Statements

Next topic

Chapter 3: Programming Projects

This Page