CODE

:
//Implementation of Stuffing and Destuffing
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int n,i;
char d[10][10];
clrscr();
printf("\t\tProgram for Stuffing and Destuffing");
printf("\n\nEnter number of dataword to be entered: ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter %d dataword: ",i+1);
scanf("%s",d[i]);
}
printf("\n\nDatawords received from user:\n\n");
for(i=0;i<n;i++)
{
printf("%s",d[i]);
printf("\n");
}
for(i=0;i<n;i++)
{
if(strcmp(d[i],"01111110")==0)
{
strcpy(d[i],"011111010");
}
}

d[i]).d[i]).i++) { if(strcmp(d[i].i++) { printf("%s".i<n. } } printf("\n\nDatawords Destuffing after receiving:\n\n")."011111010")==0) { strcpy(d[i]. printf("\n").i<n. } for(i=0.i<n. } getch()."01111110"). for(i=0. printf("\n").i++) { printf("%s". for(i=0. } .printf("\n\nDatawords send after stuffing:\n\n").

OUTPUT: .

c[8]. for(i=0.t[8].n. .h> void add1(int a[8]. void main() { int d1[8]. printf("\nEnter the 8 bit dataword1:"). add2(d1. add1(d1.d2[8].carry=0. carry=1. printf("\nEnter the 8 bit dataword2:"). printf("\nAt Sendors End:\n\n"). carry=1. void add2(int c[8].j.&d2[i]).add). getch(). printf("\t\tProgram for Checksum method").int total[8]).i<8. c[i]=0. clrscr().i++) scanf("%d".int b[8].d2.dis.int d[8].int add[8]).n.CODE: //Implementation of Checksum Method #include<stdio. for(i=0. for(i=7.i>=0.i.add).add[8].i++) scanf("%d". } else if(add[i]==2) { add[i]=0.&d1[i]).int b[8]. if(add[i]==3) { add[i]=1.i--) { add[i]=(a[i]+b[i])+carry.i<8.d2.h> #include<conio. } void add1(int a[8].int add[8]) { int i.c[8].

t.i++) printf("%d ". } } if(carry==1) { for(i=0. csum[i]=0. } else { printf("\nAddition:").} else { carry=0. else add[i]=0.i++) { if(add[i]==0) add[i]=1. } } void add2(int c[8].i<8.t[8].rec[10]. for(i=0.i<8.i<8. add1(add.i++) printf("%d ". } printf(" ").i<8.add[i]).carry=0.int total[8]) { int i.csum[8]. for(i=0. for(i=0.n. int count=0.i<8. t[7]=carry.i++) t[i]=0. .c[i]).i++) { printf("%d".add[i]).int d[8].add). } printf("\nChecksum:"). printf("\n\nData to be send :"). for(i=0.

for(i=0.i<8.d[i]).i>=0. carry=1. printf("\nAt Receivers End:"). } else if(rec[i]==2) { rec[i]=0. } else { carry=0. } printf(" ").i++) { scanf("%d".i<8. for(i=0.i++) { scanf("%d".&rec[i]).&d[i]). } printf("\nEnter the recieved checksum :").i++) scanf("%d".i++) { printf("%d". .i++) { printf("%d". for(i=0.i<8. printf("\n\n\nEnter the recieved dataword1 :"). } printf("\n\n======================="). } for(i=7. for(i=0.i<8.i--) { rec[i]=(c[i]+d[i]+rec[i])+carry.total[i]).&c[i]). carry=1. printf("\nEnter the recieved dataword2 :"). for(i=0.i<8. if(rec[i]==3) { rec[i]=1.

i<8.i++) printf("%d ".i<8. add1(rec.i<8.rec).i++) printf("%d ".i++) { if(rec[i]==0) { count++. } } .i++) t[i]=0. for(i=0. else rec[i]=0. } else { printf("\nTransmission Error").rec[i]).rec[i]). for(i=0. t[7]=carry. } } if(count==8) { printf("\nNo Transmission Error").t. } else { printf("\nChecksum: ").} } if(carry==1) { for(i=0. } printf("\nComplement:").i++) { if(rec[i]==0) rec[i]=1. for(i=0.i<8. } for(i=0.i<8.

OUTPUT: .

Sign up to vote on this title
UsefulNot useful