CProgram

# Implementation of Hamming Code

Write a C program to Implement Hamming Code.

#include<stdio.h>
#include<conio.h>
void main() {
int data[7],rec[7],i,c1,c2,c3,c;
printf(“this works for message of 4bits 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(“\nthe encoded bits are given below: \n”);
for (i=0;i<7;i++) {
printf(“%d “,data[i]);
}
printf(“\nenter 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(“\ncongratulations there is no error: “);
} else {
printf(“\nerron on the postion: %d\nthe 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:

Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0

C

C

C

### Convert temperature from degree centigrade to Fahrenheit

Write a C program to convert temperature from degrees Centigrade to Fahrenheit. #include<stdio.h> int main() { float celsius, fahrenheit; ...

### Program to find Average of three Real Numbers

Write a C program to an average of three real numbers. #include <stdio.h> main() { ...

### Find Area of Square & Circumference of a Circle

Write a C program to find the area of a square & circumference of a ...

### Find the Sphere Surface Area and Volume of a Sphere

Write a C program to find the sphere surface area and volume of a sphere. ...