sep 7
preliminaries
- introductions
- copyright, plagiarism
- 'welcome to my classroom' - Rob Jenkins, chronicle of higher ed
- tools: editors, compilers, command line, ...
Aside : Net neutrality comment request
http://www.fcc.gov/Daily_Releases/Daily_Business/2010/db0901/DA-10-1667A1.pdf
C
- compiling, running : discuss
- "hello world" - do in class
- projecteuler.net #9 (pythogrean triple whose sum is 1000) - do in class ; then look at 9a.c (attached).
- ditto for sum = 1e4, 1e5 . Discuss.
general discussion of C
First, don't forget
- tests and explicit output in comments (We'll get to gdb later; I'm content with printf for now.)
- file header with author & date, implementation comments
Second : coding style
- 2 or 4 (not 8) indent spaces
- Curlies as shown below (discuss reasons)
- Don't hurt yourself with comment styling, eh?
/* total.c | Jim M | Sep 2010
* simple class example
*
* $ gcc total.c -o total
* $ ./total
* Total of integers from 17 to 203 is 20570.
*/
#include <stdio.h>
int main(){
int i;
int low = 17;
int high = 203;
int total = 0;
for (i = low; i <= high; i++){
total += i;
}
printf("Total of integers from %i to %i is %i.\n", low, high, total);
return 0;
}
Discuss declarations and sizes; see attached sizes.c
Discuss typedefs, structs, malloc, and all that : see attached 9b.c
To come :
- arrays and pointers
- multiple files
Going on : continue reading chapter 2 in text.