0% found this document useful (0 votes)
26 views

Practical 4

The document describes a C program that performs error correction on data. It initializes arrays to store character data and binary representations. It loops through the characters, converting each to binary and storing in an array. It then calculates parity bits for each row and column, setting unused bits to 1 or 0 to make the total number of 1s even. Finally, it prints the final parity-checked data array. The program demonstrates how error correcting codes work by adding parity bits to allow detection and correction of errors in transmitted data.

Uploaded by

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

Practical 4

The document describes a C program that performs error correction on data. It initializes arrays to store character data and binary representations. It loops through the characters, converting each to binary and storing in an array. It then calculates parity bits for each row and column, setting unused bits to 1 or 0 to make the total number of 1s even. Finally, it prints the final parity-checked data array. The program demonstrates how error correcting codes work by adding parity bits to allow detection and correction of errors in transmitted data.

Uploaded by

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

PRACTICALNO: 4

Date:

Program:

#include <stdio.h>
#include <conio.h>

void main()
{
int i,a[10],h[6][9],f[8],b[4]={1,0,0,0},e[4],p[4],c,n,j,k,l,m,x,y;
char d[10]="harry";
clrscr();
l=0;
for(i=0;i<=5;i++)
{
a[i]=d[i];
printf("%c\t%x\t",d[i],a[i]);
j=7;
k=a[i];
do
{
c=k/2;
n=k%2;
f[j]=n;
j--;
k=c;
}while(c!=1);
f[j]=1;
j--;
do
{
f[j]=0;
j--;
}while(j>0);
for(m=0;m<=7;m++)
{
h[i][m]=f[m];
printf("%d",f[m]);
}
printf("\n");
}
c=0;
for(i=0;i<6;i++)
{
c=0;
l=0;
for(j=0;j<8;j++)
{
l=h[i][j];
printf("%d",h[i][j]);
if(l==1)
{
c++;
}
}
if ( (c%2) !=0 )
{
h[i][j]=1;
printf("\t%d",h[i][j]);
}
else
{
h[i][j]=0;
printf("\t%d",h[i][j]);
}
printf("\n");
}
for(i=0;i<8;i++)
{
x=0;
y=0;
for(j=0;j<6;j++)
{
y=h[j][i];
if(y==1)
{
x++;
}
}
if ( (x%2) !=0 )
{
h[j][i]=1;
}
else
{
h[j][i]=0;
}

}
for(i=0;i<8;i++)
{
x=0;
y=0;
for(j=0;j<6;j++)
{
y=h[j][i];
if(y==1)
{
x++;
}
}
if ( (x%2) !=0 )
{
h[j][i]=1;
}
else
{
h[j][i]=0;
}
}
printf("\n");
for(i=0;i<7;i++)
{
for(j=0;j<8;j++)
{
if (i==6)
{
printf("%d",h[i][j]);
}
}
}
getch ();
}

OUTPUT:
CONCLUSION:

You might also like