Skip to content

Latest commit

 

History

History
43 lines (39 loc) · 2.82 KB

Readme.md

File metadata and controls

43 lines (39 loc) · 2.82 KB

Some simple C examples for beginners

In roughly increasing order of complexity:

  • e.c - compute e from its series expansion (for loop)
  • prime.c - test if a number (provided as a command line arg) is prime (separate function)
  • factor.c - factor a number into its prime factors (recursive function)
  • sqrt.c - square root a number using Newton's method (while loop)
  • sin.c - compute the sin of a number (in radians) using trig (recursive function)
  • stats.c - compute mean and std-dev of numbers (reading data from stdin, arrays)
  • statsp.c - compute mean and std-dev of numbers (use pointers rather than explicit array indexing)
  • statsp-bug.c - previous example with a bug deliberately introduced - read the code comments (using the debugger, gdb)
  • statsv.c - compute mean and std-dev of numbers (use a typedef'd struct as a vector type)
  • statsg.c - compute mean and std-dev of numbers (using the GSL)
  • canvas1.c - first attempt at a canvas drawing app (writing a file)
  • canvas2.c - extended canvas drawing app (lines and filled triangles)
  • canvas3.c - canvas drawing example (Sierpinski triangles)
  • canvas4.c - extended canvas drawing app (circles and thick lines)
  • canvas5.c - canvas drawing example (fractal fern)
  • canvas6.c - drawing the Mandelbrot set (complex numbers)
  • canvas7.c - drawing the Lorenz attractor (Euler integration of ODEs)
  • magick.c - drawing the Mandelbrot set on an ImageMagick image (MagickWand API)
  • magickFern.c - drawing a fern on an ImageMagick image (more MagickWand API)
  • cairo.c - drawing the Mandelbrot set on a Cairo image (Cairo canvas API)
  • window.c - simple GTK app to load and display an image (GUI toolkit)
  • window2.c - simple GTK app to draw an image using Cairo (more GUI toolkit)
  • agglom - simple multi-file GTK application (multiple files, headers, Makefile)

Some links