#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;
}
Chapter 4
Answers to Selected Exercises
2. [was #2] Not in C89. Suppose that i is 9 and j is 7. The value of (-i)/j
could be either –1 or –2, depending on the implementation. On the other
hand, the value of -(i/j) is always –1, regardless of the implementation.
In C99, on the other hand, the value of (-i)/j must be equal to the value
of -(i/j).
9. [was #6]
(a) 63 8
(b) 3 2 1
(c) 2 -1 3
(d) 0 0 0
评论5
最新资源