Home Page

Programming in ANSI-C
The Basics


Compiling Summary

  1. Right-Click to download the c-code
  2. Save in the directory SDBA
  3. Open the c-code in Notepad++ or another editor
  4. Modify Code
  5. Compile: gcc -c -Wall -g xxx.c
  6. Link: gcc -o -xxx.exe xxx.o
  7. Run: xxx
  8. Debug: gdb xxx

Worksheets

UnitWorksheets / Problem Sets
0 物理 Physics:
Falling Objects

Data Processing
光學 Optics:
Ray Tracing

Simulation
數值分析 Root Finding
Numerical Analysis

Course Outline

1
Intro
1A. Introduction to Course and Milestones.
B. Install (htm) MinGW & Notepad++ prog1.swf#1-32
2
First
2⬩
3⬩
Compiling, Linking, Running, Debugging (htm), prog1.swf#33-end
2.Introduce Applications
mgrav1.swf mopt.swf#1-11 mroot1.swf
3
UML
4
Define Algorithms with UML 2algo.swf
Create UML to represent solutions to each of the above problems.
Walking Through UML design...
mguml.swf mouml.swf mruml.swf
4
Functions
5
Implement Algorithm with Functions 3func.swf#1-38 UML with pseudo-code.
Write commented code based on UML. Decide between writing your own, using library or other peoples functions.
UML + m0.cmg1com.c UML + m0.cmo1com.c UML + m0.cmr1com.c
Walking through the pseudo-code...
3func.swf#39-41 mopt2.swf#1-6 mroot.swf#1-5
5
Variables
6
7
8
Implement Data Structures with simple Variables 4var.swf#1-42
Create machine readable floating point code
mg1com.c → mg3float.c mo1com.c → mo2float.c mr1com.c → mr2float.c
Walking through "a" solution...
4var.swf#43-105 mopt2.swf#7-29 mroot2.swf#6-19
Coordinate System Needed mopt2.swf#30-74
mo2float.cmo3com.c
mo3com.cmo4float.c
Midterm
6
Pointers
10 Beyond Variables: Pointers & Addresses 5ptr.swf#1-18, 13ptr1.pps
Use Pointers & addresses to get input using fscanf() in stdio.h
mg3float.c → mg4ptr.c mo4float.c → mo5ptr.c mr2float.c → mr3ptr.c
Walking through "a" solution...
5ptr.swf#18-43 mopt2.swf#75-end mroot2.swf#19-35
7
Flow
Repetition and Decision Structures in C 6flow.swf Operation Counts (swf)
Apply flow control for each of the problems
Repetition + File Entry → Less typing errors
mg4ptr.c → mg5loop.c & (mgdt.csv)
Conditional → Fix lens equation
mo5ptr.c → mo6if.c
Conditional + Repetition → Auto Converge
mr3ptr.c → mr4loop.c
Walking through "a" solution...
mgfloa.swf mofloa1.swf mrfloa.swf
1 → 2 files mo6if.c → mo7split.c + molib.c + molib.h take the n-root-p
mr4loop.c → mr4nrootp.c
Repetition → Lens System
mo6if.c → mo8loop.c
A Solution: mofloa2.swf
Structuring Data (An introduction)
8
Arrays
OverviewArrays → Summary & Application 7arr.swf
Modify code to use arrays to separate input, calc, output phases
mg5loop.c (mgdt.csv) → UML → mg6array.c mo8loop.c, molib.c,molib.h, mo8.bat →UML →mo9array.c Generalize: ax3 + bx2 + cx + d = 0
mr4nrootp.c → mr5array.c
Walking through "a" solution...
mgarra.swf moarra.swf mroot2.swf#70
9
Records
Records → Summary & Application 7rec.swf
Use records to link x,y data & remove pointers from user functions (i.e. use return)
mg6array.c(mgdt.csv) → mg7rec.c mo9array.c, molib.c, molib.h → moBrec.c -
Walking through "a" solution...
mgrav2.swf#96 mopt.swf#262 -
10
Final, Files...
Final Versions of Codes
mg7rec.c (mgdt.csv) moArec.c, moBrec.c