Bits 2 C Computer Science:
From Bits to C and Beyond

[Index] [Handouts] [pbl] [References & Tools]


Part 1 Computer Basics

Part 2 Programming in C

Notes: Firefox & Chrome: Left-Click on the c-program's filename and copy into jEdit.
  Internet Explorer: Right-Click on the filename and save in the SDBA directory on your computer.
  You need to have jlib.c and jlib.h compiled by gcc -o jlib.c so that you have jlib.o in the same directory as your code.
  VP-diagrams & next steps are accessable from index.swf in the application section of the viewgraphs

物理 Physics: Falling Objects

光學 Optics: Ray Tracing

數值分析 Numerical Analysis: Roots

Work Sheets Gravity Work Sheet Ray Tracing Work Sheet Root Finding Work Sheet
ThinkingWrite UML to represent problem (or a simplification) clearly
Functions From UML to commented pseudo-code. Deciding between writing one's own functions and using library or other people's functions Start with the simple Program m0.c (simple program), which you can compile/link/run with m0.txt or m0gdb.txt (to add information for debugger). Modify it according the UML diagram. Your code should be commented pseudo-code that calls functions.
UMLmg1com.c UMLmo1com.c UMLmr1com.c
Variables mg1com.cmg2fixed.c
(Implement w/Fixed Point)
(Implement w/ Floating Point)
1. mo1com.cmo2float.c (Implement w/ Floating Point)
2. mo2float.cmo3com.c(Add commented code to use coordinate system)
3. Finally mo3com.cmo4float.c(Implement coordinate system code w/floating point)
(Implement /Floating Point)
PointersUse Pointers & addresses to get input using stdio.h function fscanf() For Physics and Optics Problem, get 2 piece of input with a single fscanf() call.
mg3float.cmg4ptr.c mo4float.cmo5ptr.c mr3ptr.cmr3ptr.c
Flowmg4ptr.cmg5loop.c & mgdt.csv (Purpose: Repetition + File Entry → Less typing errors) 1. mo5ptr.cmo6if.c (Conditional: Correcting Lens Equation)
2. mo6if.cmo7split.c + molib.c + molib.h (Split User Functions into three files)
3. mo7split.cmo8loop.c (Repetition for multiple lens)
mr3ptr.cmr4loop.c (Add Conditional + Repetition to zoom into root automatically)
Arrays mg5loop.c & mgdt.csvUMLmg6array.c (Formatted Output table: Can Easy check data) mo8loop.c, molib.c, molib.h, mo8.batUMLmo9array.c (Separate input, calculation & output phases) 1.mr4loop.cmr5array.c (Generalize equation that we can solve) (alternate version of mr4loop-alt.c)
2.(Bonus) Try to write code to take the n-root-p where n is an integer mr5array-nrootp.c
Records mg6array.c, mgdt.csvmg7rec.c Use a record to link the observables and their time coordinates mo9array.c, molib.c, molib.hmoArec.c Connect lens: lf and lx in record Opt → moBrec.c getOptR: Make pointer free version mr5array.cmr6rec.c Use a record to link the x,y data
Text Physics mg7rec.c & mgdt.csvOptics moArec.c, moBrec.cNumerical Analysis mr6rec.c