Sie sind auf Seite 1von 3

ROLLNO:

EXPERIMENT NO:
AIM:
PROGRAM:
#include<stdio.h> cs[c]=t[e++];

#include<string.h> }while(e<=a+N-1);

#define N strlen(g) }

char int main()


t[28],cs[28],g[]="10001000000100001";
{
int a,e,c;
printf("\nEnter data : ");

scanf("%s",t);
void xor(){

for(c = 1;c < N; c++) printf("\n----------------------------------------")


;
cs[c] = (( cs[c] == g[c])?'0':'1');
printf("\nGeneratng polynomial : %s",g);
}
a=strlen(t);

for(e=a;e<a+N-1;e++)
void crc(){
t[e]='0';
for(e=0;e<N;e++)

cs[e]=t[e]; printf("\n----------------------------------------")
do{ ;

if(cs[0]=='1') printf("\nModified data is : %s",t);

xor();
printf("\n----------------------------------------")
for(c=0;c<N-1;c++) ;

cs[c]=cs[c+1]; crc();
printf("\nChecksum is : %s",cs); }while(e==0 || e>a+N-1);

for(e=a;e<a+N-1;e++) t[e-1]=(t[e-1]=='0')?'1':'0';

t[e]=cs[e-a];
printf("\n----------------------------------------")
;
printf("\n----------------------------------------")
; printf("\nErroneous data : %s\n",t);

printf("\nFinal codeword is : %s",t); }

crc();
printf("\n----------------------------------------")
; for(e=0;(e<N-1) && (cs[e]!='1');e++);

printf("\nTest error detection 0(yes) if(e<N-1)


1(no)? : "); printf("\nError detected\n\n");
scanf("%d",&e); else
if(e==0) printf("\nNo error detected\n\n");
{

do{ printf("\n----------------------------------------\n
");
printf("\nEnter the position where
error is to be inserted : "); return 0;

scanf("%d",&e); }
OUTPUT:

Das könnte Ihnen auch gefallen