Script started on Wed Sep 24 17:18:48 2025 macbook:programs> cd C_ch6 macbook:C_ch6> grep OUT *.c count_words.c:#define OUT 0 count_words.c: state = OUT; count_words.c: state = OUT; count_words.c: else if (state == OUT) { macbook:C_ch6> cat count_words.c #include #define IN 1 #define OUT 0 int main () { int c, nl, nw, nc, state ; state = OUT; nl = nw = nc = 0; while ((c = getchar()) != EOF) { ++nc; if (c == '\n') nl++; if (c == ' ' || c == '\n' || c == '\t') state = OUT; else if (state == OUT) { state = IN; ++nw; } } printf("%d %d %d\n",nc, nw, nl); return 0; } macbook:C_ch6> echo attendance code 810 attendance code 810 macbook:C_ch6> gcc count_words.c macbook:C_ch6> ls *txt example_file.txt example_file2.txt macbook:C_ch6> cat example_file2.txt abcdefghi xyz macbook:C_ch6> ./a.out < example_file2.txt 14 2 2 macbook:C_ch6> echo "one two three four" > ex1.txt macbook:C_ch6> echo "one, two, three, four" > ex2.txt macbook:C_ch6> echo "one,two, three ,four" > ex3.txt macbook:C_ch6> ./a.out < ex1.txt 19 4 1 macbook:C_ch6> ./a.out < ex2.txt 22 4 1 macbook:C_ch6> cat ex3.txt | ./a.out 21 3 1 macbook:C_ch6> echo " one two three four " > ex4.txt macbook:C_ch6> ./a.out < ex4.txt 21 4 1 macbook:C_ch6> echo " one two three four " > ex5.txt macbook:C_ch6> ./a.out < ex5.txt 24 4 1 macbook:C_ch6> echo " one two three fo three four " > ex6.txt macbook:C_ch6> echo " one 6.txtut < ex5.txt 69 4 1 macbook:C_ch6> echo "! : ;;;; ,,,," > ex7.txt macbook:C_ch6> ./a.out < ex7.txt 14 4 1 macbook:C_ch6> vi short_circuit.txt macbook:C_ch6> cat short_circuit.txt if (true || false) --> true if (true || true) --> true short circuit eval means that we don't have to check the second condition when the first is true with an OR if (false && false) --> false if (false && true) --> false short circuit eval means that we don't have to check the second condition when the first is false with an AND where this comes in handy: if ((i < ARRAY_LENGTH) && (myarray[i] == some_value)) macbook:C_ch6> exit Saving session... ...saving history...truncating history files... ...completed. Deleting expired sessions...none found. Script done on Wed Sep 24 18:37:42 2025