//hamming code #include #include #include void main() { int m; int r; int db[30]; cout<<"\n Enter frame size:"; cin>>m; int i,j,k; //Some temp variables cout<<"\n Enter Frame :"; for (i=0;i>db[i]; } cout<<"\n Enter redundancy bits: "; cin>>r; //Entered Frame cout<<"\n Frame :\n "; for(i=0;i=0;i--,j++) { temp[j]=db[i]; } for (i=0;i0;i--) { cout<0) { i4++; if(i7==1) { break; } else { i7=i7/2; } } i3=0; // Consider even parity //Calculating redundancy bit and parity for(i2=1;i2<=l;i2++) { //reset a1 frame for(i6=0;i6<4;i6++) { a1[i6]=-1; } //find binary conversion for each position i7=i2; i6=0; while(i7>0) { if(i7==1) { a1[i6]=1; break; } else if(i7==0) { a1[i6]=0; } else { a1[i6]=i7%2; i7=i7/2; } i6++; } //check that the binary conversion is having bit at specific position or not //if yes calculate parity if(a1[i4]==1) { if(df[i2]==1) { i3++; } } } //Display Parity //Add redundancy bit in data frame //odd parity -> 1 :: even parity -> 0 if(i3%2==0) { df[i1]=0; rb[i5]=0; } else { df[i1]=1; rb[i5]=1; } i5++; //Print current frame cout<<"\n R"<0;i2--) { cout<<" "<>eb; cout<<"\n Bit at position "<0;i--) { cout<<" "<0) { i4++; if(i7==1) { break; } else { i7=i7/2; } } i3=0; // Consider even parity //Calculating redundancy bit and parity for(i2=1;i2<=l;i2++) { //reset a1 frame for(i6=0;i6<4;i6++) { a1[i6]=-1; } //find binary conversion i7=i2; i6=0; while(i7>0) { if(i7==1) { a1[i6]=1; break; } else if(i7==0) { a1[i6]=0; } else { a1[i6]=i7%2; i7=i7/2; } i6++; } //check that the binary conversion is having bit at specific position or not //if yes calculate parity if(a1[i4]==1) { if(df[i2]==1) { i3++; } } } //Display Parity //Add redundancy bit in data frame //odd parity -> 1 :: even parity -> 0 if(i3%2==0) { df[i1]=0; rb[i5]=0; } else { df[i1]=1; rb[i5]=1; } i5++; k=k*2; } } cout<<"\n Redundancy bits:"; for(i=0;i