translation of previous neural network experiment to c