//this code is designed by codenation.
//6:55 5/12/2020
#include<stdio.h>
int main()
{
int n1,i,hamming_distance=0,temp;
printf("enter the size of data strings:\n");
scanf("%d",&n1);
int str1[n1],str2[n1];
printf("enter the first data string :\n");
for(i=0;i<n1;i++)
{
printf("enter the %d bit :\n",i+1);
scanf("%d",&str1[i]);
}
printf("enter the second data string :\n");
for(i=0;i<n1;i++)
{
printf("enter the %d bit :\n",i+1);
scanf("%d",&str2[i]);
}
printf("entered first string is :\n");
for(i=0;i<n1;i++)
{
printf("%d",str1[i]);
}
printf("\n");
printf("entered first string is :\n");
for(i=0;i<n1;i++)
{
printf("%d",str2[i]);
}
printf("\n\n");
for(i=0;i<n1;i++)
{
temp=str1[i]^str2[i];
if(temp==1)
{
hamming_distance++;
}
}
printf("the hamming distance between two data strings is : %d\n\n",hamming_distance);
printf("the %d bit error is detected.\n",hamming_distance);
}
//this code is developed by codenation.
Comments
Post a Comment