This is a simple C genetic algorithm example, it's not perfect but works fine without chaos errors in memory nor results, it is tested in fedora 14 with Valgrind-3.5.0 and compiled by gcc version 4.5.1.
This program finds an equation composed by addition/subtraction for the given target number.
An example output for target number 27:
binary string: 01111010011010110110101000011000 - fitness: 2
binary string: 01111010011010110110101000011000 - fitness: 2
binary string: 01111010011010110110101000011000 - fitness: 2
binary string: 01111010011010110110101000011000 - fitness: 2
binary string: 00110010101100101011011010100100 - fitness: 1
binary string: 00101010001001001011010110100110 - fitness: 0
2+24-5+6
To change target number, just edit line
#define TARGET 27
The full source code has been given here:
http://pastebin.com/40Y5U1sY[
^].