|
|
|
Chapter 3Answers to Selected Exercises2. [was #2] (a)printf("%-8.1e", x);
(b) printf("%10.6e", x);
(c) printf("%-8.3f", x);
(d) printf("%6.0f", x);
5. [was #8] The values of Answers to Selected Programming Projects1. [was #4; modified] #include <stdio.h> int main(void) { int month, day, year; printf("Enter a date (mm/dd/yyyy): "); scanf("%d/%d/%d", &month, &day, &year); printf("You entered the date %d%.2d%.2d\n", year, month, day); return 0; } 3. [was #6; modified] #include <stdio.h> int main(void) { int prefix, group, publisher, item, check_digit; printf("Enter ISBN: "); scanf("%d-%d-%d-%d-%d", &prefix, &group, &publisher, &item, &check_digit); printf("GS1 prefix: %d\n", prefix); printf("Group identifier: %d\n", group); printf("Publisher code: %d\n", publisher); printf("Item number: %d\n", item); printf("Check digit: %d\n", check_digit); /* The five printf calls can be combined as follows: printf("GS1 prefix: %d\nGroup identifier: %d\nPublisher code: %d\nItem number: %d\nCheck digit: %d\n", prefix, group, publisher, item, check_digit); */ return 0; } Copyright © 2008, 1996 W. W. Norton & Company, Inc. All rights reserved. |