Review Questions

  1. Run Listing 4.1 again, but this time give your first and last name when it asks you for your first name. What happens? Why?

  2. Assuming that each of the following examples is part of a complete program, what will each one print?

    1. printf("He sold the painting for $%2.2f.\n", 2.345e2);
      
    2. printf("%c%c%c\n", 'H', 105, '\41');
      
    3. #define Q "His Hamlet was funny without being vulgar."
      printf("%s\nhas %d characters.\n", Q, strlen(Q));
      
    4. printf("Is %2.2e the same as %2.2f?\n", 1201.0, 1201.0);
      
  3. In Question 2.c., what changes could you make so that string Q is printed out enclosed in quotes?

  4. It's find the error time!

     define B booboo define X 10 main(int) { int age; char name; printf("Please enter your first name."); scanf("%s", name); printf("All ...

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.