Hi , i have a project in neural network (hebbian learning rule) i just want to apply it (AND gate) , I wrote a simple program but i get it to work just like it should can some one help me tracing the program .

Input pattern 1 (0,0) corresponding output -1

Input pattern 2 (0,1) corresponding output -1

Input pattern 3 (1,0) corresponding output -1

Input pattern 4 (1,1) corresponding output 1

here is the program :-

the weird thing is after enter the input patterns i get weight =[1 2 2] which supposed to be w=[1 1 1] .ThanksCode:#include <iostream> using namespace std; int main() { int x[4][3],w[3],y[4][1],i,j,p; for(i=0;i<=2;++i) w[i]=0; for(p=1;p<=4;++p) x[p][0]=1; for(p=1;p<=4;++p) { cout<<"Enter the input Pattern number "<<p<<" : \n"; for(i=1;i<=2;++i) cin>>x[p][i]; cout<<"Enter the corresponding output \n"; for(j=1;j<=1;++j) cin>>y[p][j]; for(i=0;i<=2;++i) for(j=1;j<=1;++j){ w[i]+=x[p][i]*y[p][j]; cout<<endl; } } cout<<"The final weights = [ "<<w[0]<<" "<<w[1]<<" "<<w[2]<<" ]"<<endl; clrscr(); return 0; }