In regards to the statistics:

Isn't variance (what you have called "mean square deviation") supposed to be the sum of the squared differences divided by (n-1) not n?

In regards to the last program I did, this is it. It is a single neuron following the perceptron model, to do pattern classification of inputs:

Code:
#include <stdio.h>
#include <math.h>
#include <conio.h>
#include <fstream.h>

double w[3] = {1,1,1}; // some inital weights
double mu = 0.2;  // learning rate

int CalculateValue(int x1, int x2);
void UpdateWeights(int error, int x1, int x2);

int main(){

	bool finished;
	int error, count = 0;
	int trainingData[4][3] = {{-1,1,1},{0,0,0},{-1,-1,1},{1,0,0}};
	do{
		finished = true;
		for (int i = 0; i < 4; i++){
			count++;
			error = trainingData[i][2] -
				CalculateValue(trainingData[i][0],trainingData[i][1]);
			if (error != 0){
				finished = false;
				UpdateWeights(error,trainingData[i][0],trainingData[i][1] );
			}
		}
	}while(!finished);
	ofstream outStream("prob5o.txt");
	outStream << "Results: " << endl;
	for (int i = 0; i < 3; i++){
		outStream << "w[" << i << "] = " << w[i] << endl;
	}
	outStream << endl << "Total, we performed " << count << " iterations";
}

int CalculateValue(int x1, int x2){
   // new variables so we don't have to worry about casting/mixed type math.
	double d_x1 = x1;
	double d_x2 = x2;

	double intermediate = w[0] + w[1]*d_x1 + w[2] * d_x2;
	//intermediate is our net function
	//We use a step activation function
	if (intermediate >= 0) return 1;
	return 0;
}

void UpdateWeights(int error, int x1, int x2){
	double d_error = error;  // same reason as before, make doubles
	double d_x1 = x1;
	double d_x2 = x2;

	w[0] = w[0] + mu * d_error;
	w[1] = w[1] + mu * d_error * d_x1;
	w[2] = w[2] + mu * d_error * d_x2;
}