answersLogoWhite

0


Best Answer

/*

WRITTEN BY : BIBHAKAR JHA

OBJECTIVE: TO IMPLEMENT HAMMING CODE IN C

*/

// PROGRAM CODE :

#include<stdio.h>

#include<conio.h>

#include<string.h>

#include<math.h>

void main()

{

char sender[20],buffer[50],reciver[20];

int d,p=0,i=0,j,k,length,power,count;

clrscr();

printf("ENTER THE MESSAGE IN BIT FORM:- ");

gets(sender);

d=strlen(sender);

//power

for(p=0; ;p++)

{

if(pow(2,p)>=d+p)

{

break;

}

}

p--;

/* COPY THE BITS INTO BUFFER */

i=1;

power=0;

j=0;

do

{

if(i==pow(2,power))

{

buffer[i]='0';

power++;

i++;

}

else

{

buffer[i]=sender[j];

j++;

i++;

}

}while(j<=d);

buffer[i]='\0';

//APPLY BIT IN CODE

count=0;

length=d+p;

j=0;

for(j=0;j<=p;j++)

{

k=pow(2,j);

for(i=k+1;i<=length; )

{

if(k==1)

{

if(buffer[i]=='1')

{

count++;

}

i=i+2;

}

else

{

if(buffer[i]=='1')

{

count++;

}

i++;

if(i%k==0)

{

i=i+k;

}

}

}

if(count%2==1)

{

buffer[k]='1';

}

count=0;

}

printf(" ENCODED MESSAGE IS \n ");

i=1;

do

{

printf("%c",buffer[i]);

i++;

}while(buffer[i]!='\0');

getch();

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a Program to implement error correction using hamming code?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a program to implement prim's algorithm?

dfgbrgffee


Write the generator matrix for the hamming code 51?

i want hamming code matrix (h and g)


Write A program to implement insertion using AVL trees?

yes


Write a program to implement domain and referential integrity?

give me the program which can related on domain and referential integrity.


Write a program in c plus plus to implement macro processor?

Don't write, it is already written, google for 'cpp'.


Write a program in c language to implement framing methods like character stuffing?

A program in c language to implement framing methods like character stuffing can be grave sizeCRC-32 and the variable c50.


Write a program to implement a line using slope intercept formula?

lund lelo mooh mein


Write a program of binary heap in c or c language?

to implement operations on binary heap in c


Write a C program to implement excelp system call?

You are not able to do that, but you can write a program, that uses the system-call./* exectest.c */#include int main (void){execlp ("/bin/ls", "ls", "-ld", ".", NULL);return 0;}


Write a program to implement the various operations on string such as length of string concatenation reverse of a string copy of a string to another in VB?

what is string


Write a program in C language to implement the apriori algorithm?

JavaScript is one program that has been written in C to implement the Apriori algorithm. There are also several other known programs available on the Internet that implement it as well.


Advantages of the correction fluid?

An advantage of correction fluid is that you can use it to cover up mistakes. You can also write on the fluid whenever it dries.