Programming Exercises

I l @ ve RuBoard

Programming Exercises

  1. Write a program that asks for your first name and then your last name , and then prints the names in the format last, first.

  2. Write a program that requests your first name and does the following with it:

    1.  Prints it enclosed in double quotation marks. 
    2.  Prints it in a field 20 characters wide, with the whole field in quotes. 
    3.  Prints it at the left end of a field 20 characters wide, with the whole field enclosed in quotes. 
    4.  Prints it in a field three characters wider than the name. 
  3. 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 formats:

    1.  The input is 21.3 or 2.1e+001. 
    2.  The input is +21.290 or 2.129E+001. 
  4. Write a program that requests your height in inches and your name, and then displays the information in the following form:

     Dabney, you are 6.208 feet tall 

    Use type float , and use / for division.

  5. Write a program that requests the user's first name and then the user 's last name. Have it print the entered names on one line and the number of letters in each name on the following line. Align each letter count with the end of the corresponding name, as in the following:

     Melissa Honeybee       7        8 

    Next have it print the same information, but with the counts aligned with the beginning of each name.

     Melissa Honeybee       7        8 
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