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 ...

Get C Primer Plus®, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.