0% found this document useful (0 votes)
453 views3 pages

Error Correction-Hamming Code

This document describes implementing error detection and correction using Hamming code. It explains encoding 4 bits of data by calculating the parity bits and transmitting the encoded 7 bits. Upon receiving the bits, it checks for errors by recalculating the parity bits and identifying the position of any incorrect bit, which is then corrected. The code sample demonstrates encoding data, receiving bits, checking for errors using Hamming code calculations, and correcting any error found. The output verifies that errors are correctly detected and corrected when present in the received data.

Uploaded by

Ashok Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
453 views3 pages

Error Correction-Hamming Code

This document describes implementing error detection and correction using Hamming code. It explains encoding 4 bits of data by calculating the parity bits and transmitting the encoded 7 bits. Upon receiving the bits, it checks for errors by recalculating the parity bits and identifying the position of any incorrect bit, which is then corrected. The code sample demonstrates encoding data, receiving bits, checking for errors using Hamming code calculations, and correcting any error found. The output verifies that errors are correctly detected and corrected when present in the received data.

Uploaded by

Ashok Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Implementation of Error Detection / Error Correction Techniques

Ex.No:
Date:
Aim:
To implement the Error Detection / Error Correction Techniques using Hamming code
Procedure:
1. Get Sending data in array
2. Get receiving data in another array
3. Calculate encoded data using hamming algorithm
4. Enter the received data
5. Check whether data is received with error or not using Hamming algorithm

Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int data[7],rec[7],i,c1,c2,c3,c;
printf("Error detection and correction by Hamming Code for message of 4 bits in size \n enter
message bit one by one:");
scanf("%d%d%d%d",&data[0],&data[1],&data[2],&data[4]);
data[6]=data[0]^data[2]^data[4];
data[5]=data[0]^data[1]^data[4];
data[3]=data[0]^data[1]^data[2];
printf("the encoded bits are given below:\n");
for (i=0;i<7;i++)
{
printf("%d",data[i]);
}
printf("\n enter the received data bits one by one:");
for (i=0;i<7;i++)
{
scanf("%d",&rec[i]);
}
c1=rec[6]^rec[4]^rec[2]^rec[0];
c2=rec[5]^rec[4]^rec[1]^rec[0];
c3=rec[3]^rec[2]^rec[1]^rec[0];
c=c3*4+c2*2+c1 ;
if(c==0)
{
printf("\n there is no error in transmission : ");
}
else
{
printf("\n error on the postion: %d \n the correct message is \n",c);
if(rec[7-c]==0)
rec[7-c]=1; else
rec[7-c]=0;
for (i=0;i<7;i++)
{
printf("%d ",rec[i]);
}
}
getch();
}
Output:
When no error in transmission

When error in transmission

Result:
Thus the implementation of Error Detection / Error Correction Technique was implemented and output is
verified

You might also like