Solution for Exercise 9-5
ex0905
#include <stdio.h> int main() { int duo; for(duo=2;duo<=100;duo=duo+2) { printf("%d\t",duo); } putchar('\n'); return(0); }
Output
2 4 6 8 10 12 14 16 18 20 2
2 24 26 28 30 32 34 36 38 40 4
2 44 46 48 50 52 54 56 58 60 6
2 64 66 68 70 72 74 76 78 80 8
2 84 86 88 90 92 94 96 98 100
Notes
* The sample output above reflects an approximation of what you see on a standard 80-column display. The output is really one long line of text, which wraps at the 80th column.
* The third part of a for statement doesn't always have to increment the counter variable by one.
Copyright © 1997-2024 by QPBC.
All rights reserved