CS 24000 Study Guide - Midterm Guide: Grep, Standard Streams, Gnu Compiler Collection

28 views3 pages

Document Summary

It is commonly used to iterate a known number of times: syntax is similar to java, you cannot declare a variable inside the parentheses of a for loop (for()) as such you could in java. #include main() int fahr; for (fahr = 0; fahr <=300; fahr += 20) { printf( %3d %6. 1f\n , fahr, (5. 0/9. 0)*(fahr-32)); Symbolic constants: #define symbol constant, substitutes symbol with constant, example: #define step 20 main() { int fahr; for (fahr = lower; fahr <=upper; fahr += step) { printf( %3d %6. 1f\n , fahr, (5. 0/9. 0)*(fahr-32)); #include main() int nc = 0; while (getchar() != eof) { nc++; printf( number of characters: %d\n , nc); gcc g o chcount chcount. c. Number of characters: 37 (assuming myfile. txt has 37chars) Count lines: a line terminator character or new line is represented as \n", counting the number of lines is the same as counting the number of these characters in a file.