answersLogoWhite

0

/*

written by: Bibhakar Jha;

objective : to implement CRC in C Programming language;

*/

//Program code to add CRC check bit

#include

#include

#define N strlen(g)

char t[28],cs[28],g[]="10001000000100001";

int a,e,c;

void xor()

{

for(c = 1;c < N; c++)

cs[c] = (( cs[c] == g[c])?'0':'1');

}

void crc()

{

for(e=0;e

cs[e]=t[e];

do{

if(cs[0]=='1')

xor();

for(c=0;c

cs[c]=cs[c+1];

cs[c]=t[e++];

}while(e<=a+N-1);

}

int main()

{

clrscr();

printf("\nEnter data : ");

scanf("%s",t);

printf("\n----------------------------------------");

printf("\nGeneratng polynomial : %s",g);

a=strlen(t);

for(e=a;e

t[e]='0';

printf("\n----------------------------------------");

printf("\nModified data is : %s",t);

printf("\n----------------------------------------");

crc();

printf("\nChecksum is : %s",cs);

for(e=a;e

t[e]=cs[e-a];

printf("\n----------------------------------------");

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

printf("\n----------------------------------------");

printf("\nTest error detection 0(yes) 1(no)? : ");

scanf("%d",&e);

if(e==0)

{

do{

printf("\nEnter the position where error is to be inserted : ");

scanf("%d",&e);

}while(e==0 e>a+N-1);

t[e-1]=(t[e-1]=='0')?'1':'0';

printf("\n----------------------------------------");

printf("\nErroneous data : %s\n",t);

}

crc();

for(e=0;(e

if(e

printf("\nError detected\n\n");

else

printf("\nNo error detected\n\n");

printf("\n----------------------------------------\n");

getch();

return 0;

}

User Avatar

Wiki User

13y ago

What else can I help you with?

Related Questions

Write a c program to accept a numbers and generate square root cube and exponential values?

write a c program to accept a number and generate a square root cube and exponential values


Write a program to generate uppercase using cSharp?

string s = "asdfqwer"; s = s.ToUpper(System.Globalization.CultureInfo.CurrentCulture);


Can you write a program to generate sinx table where x varies from 0 to 180 in steps of 15?

Yes, I can.


Write a c program to generate student mark details using union and find total and average and grade?

write a c program to display marks,total,average,grade using union


How do I write a program to do the following... Write a VBA code to take the TippingBucketData.txt file and process it to generate an output file.?

Without knowing the contents of the TippingBucketData.txt file nor how to process it, it would be impossible to say how such a program would be written.


When was Bushfire CRC created?

Bushfire CRC was created in 2003.


When was Poultry CRC created?

Poultry CRC was created in 2003.


When was CRC Press created?

CRC Press was created in 1973.


Does interpreter generate an object program from the source program?

No, that's what the compiler does.


What is the full form of CRC?

CRC: Cyclical Redundancy CheckA term CRC is used in datalink protocols often used in transmission ..The CRC is computed while the packet is being transmitted and then incorporated in a trailer. Similarly, the receiver computes the CRC and compares it with the transmitted one. From both points of view, it is better to have the CRC in a trailer


Write an assembly language program to generate a square wave of 10khz and 5Mhz clock?

You will need to have a little bit of computer science knowledge. This will help you to make the programing.


When was CRC Churches International created?

CRC Churches International was created in 1945.