CSCI 235 — Checkpoint alpha

Stuff to look at

Requirements for programming assignment

Tips on programming

When things go wrong

Read the compiler error messages and fix them yourself. The compiler cannot determine your intent, but it can tell you where your program goes wrong. Fix your errors one at a time.

$ make
collatz.c: In function ‘collatz’:
collatz.c:9:13: error: expected ‘;’ before ‘n’
       n = 3 n + 1 ;
             ^
$ make
collatz.c: In function ‘collatz’:
collatzc:6:15: error: lvalue required as left operand of assignment
     if (n % 2 = 0) {
               ^
$ make
collatz.c: In function ‘collatz’:
collatz.c:7:11: error: ‘m’ undeclared (first use in this function)
       n = m / 2 ;
           ^
collatz.c:7:11: note: each undeclared identifier is reported only once for each function it appears in
$ make
collatz.c: In function ‘print_table’:
collatz.c:29:5: warning: unknown conversion type character 0xa in format [-Wformat=]
     fprintf(stdout, "%4d --> %8\n", i, table[i]) ;
     ^
collatz.c:29:5: warning: too many arguments for format [-Wformat-extra-args]

Registers and variables

Take a look at an old CSCI 320 homework that shows code in both the MIPS32 and x86-64 instruction sets. Notice the heavy use of registers for storing variables. Now look at the annotated code.