Chapter 6
2, 7, 70, 64, 8, 2
It would produce the following output:
36 18 9 4 2 1
x > 5
scanf("%lf",&x) != 1
x == 5
scanf("%d", &x) == 1
x != 5
x >= 20
Line 4: Should be list[10].
Line 6: Commas should be semicolons.
Line 6: Range for i should be from 0 to 9, not 1 to 10.
Line 9: Commas should be semicolons.
Line 9: >= should be <=. Otherwise, when i is 1, the loop never ends.
Line 10: There should be another closing brace between lines 9 and 10. One brace closes the compound statement, and one closes the program. In between should be a return 0; line.
Here's a corrected version:
#include <stdio.h〉 int main(void) { /* line 3 */ int i, j, list[10]; /* line 4 */ for (i = 0; i < 10; i++) /* line 6 */ { /* line 7 */ list[i] = 2*i + 3; /* line 8 */ for (j = 1; ...
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.