O'Reilly logo

C Primer Plus, Fourth Edition by Stephen Prata

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Programming Exercises

  1. Write a program that asks for your first name, 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 (the number of digits shown in the exponent may be different for your system):

    1. The input is 21.3 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required