Hamming code implementation in C++ made Simple

preview_player
Показать описание
Here is the link for the theory explanation of hamming code with example

Рекомендации по теме
Комментарии
Автор

Indian guy? has to be awesome tutorial, thank you very much!!!

Zyx
Автор

where is the code link bro?? u hv given tht nnsense job sites

MdAsif-eolm
Автор

Thank you very much. You helped me a lot.

vladometov
Автор

I don't understand what is use of array a[].actually main program start at point where u receiving 7 bit code is it true??
Give reply fast pls

shubhamandhale
Автор

I think its a wrong code because the first and second array are not related to each other @Thecodersbay pls reply?

anupmallah
Автор

the 2 arrays ( a[ ] and b[ ] ) should be related, where the Generated and Received codes are related?

debug
Автор

Как обычно, только какой-то Индус может помочь решить любую задачу!

Arsio-wy
Автор

How to demonstrate using transmitter and receiver

vinayaklaxmanalur
Автор

it's very straight forward, thoda sa coding kr deta, baaki sahi h

mohitgedar
Автор

Yaar teri website me kahi bhi koi code nahi hai

jk
Автор

#include<iostream>

using namespace std;

int main() {
int a[10];
int b[10], c, c1, c2, c3, i;

cout<<"Enter 4 bits of data one by one\n";
cin>>a[0];
cin>>a[1];
cin>>a[2];
cin>>a[4];

//Calculation of even parity
a[6]=a[0]^a[2]^a[4];
a[5]=a[0]^a[1]^a[4];
a[3]=a[0]^a[1]^a[2];

cout<<"\nHamming code is:\n";
for(i=0;i<7;i++)
cout<<a[i];

cout<<"\n\nEnter received a bits one by one\n";
for(i=0;i<7;i++)
cin>>b[i];

c1=b[6]^b[4]^b[2]^b[0];
c2=b[5]^b[4]^b[1]^b[0];
c3=b[3]^b[2]^b[1]^b[0];

c=c3*4+c2*2+c1 ;

if(c==0) {
cout<<"\nNo error while transmission of data\n";
}
else {
cout<<"\nError on position "<<c;
cout<<"\nData sent : ";
for(i=0;i<7;i++)
cout<<a[i];

cout<<"\nData received : ";
for(i=0;i<7;i++)
cout<<b[i];

cout<<"\nCorrect message is\n";

//if errorneous bit is 0 we complement it else vice versa
if(b[7-c]==0)
b[7-c]=1;
else
b[7-c]=0;
for (i=0;i<7;i++) {
cout<<b[i];
}
}
return 0;
}

dhiraj