Sie sind auf Seite 1von 1

/* Function defination for even parity error checking */

void even_parity(int data[8][6])


{
int count=0,i,j;
printf("\n\t\t you are going to check with even parity.");
/* Loop to count the no's of 1 in sending data & add the parity bit
Horizontally */
for(i=0;i<7;i++)
{
for(j=0;j<5;j++)
{
if(data[i][j]==1)
count++;
}
if(count%2==0)
data[i][j]=0;
else
data[i][j]=1;
count=0;
}
/* Vertically */
for(i=0;i<6;i++)
{
for(j=0;j<7;j++)
{
if(data[j][i]==1)
count++;
}
if(count%2==0)
data[j][i]=0;
else
data[j][i]=1;
count=0;
}
printf("\n\t\t sender will send : \n\t\t");
/* Loop to print the sending data after adding parity bit */
for(i=0;i<8;i++)
{
for(j=0;j<6;j++)
{
printf(" %d",data[i][j]);
}
printf("\n\t\t");
}
}

Das könnte Ihnen auch gefallen