Free Academic Seminars And Projects Reports
Program the CRC 12 on a data set of characters - Printable Version

+- Free Academic Seminars And Projects Reports (https://easyreport.in)
+-- Forum: Academic (https://easyreport.in/forumdisplay.php?fid=41)
+--- Forum: Study guide (https://easyreport.in/forumdisplay.php?fid=63)
+---- Forum: Technical (https://easyreport.in/forumdisplay.php?fid=64)
+---- Thread: Program the CRC 12 on a data set of characters (/showthread.php?tid=52059)



Program the CRC 12 on a data set of characters - mvsushmareddy - 10-04-2017

Code:
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int loop,loop1,loop2,temp,temp1,flen;
char frame[100]={'0'};
char comp[17]={'0'};
char quat[17]={'0'};
char generator[17]={'1','1','0','0','0','0','0','0','1','0','1'};
clrscr();
printf(" enter the frame:\n\t");
for(loop=0;loop<88;loop++)
{
frame[loop]=getch();
temp=frame[loop];
if(temp!=13&&temp!=48&&temp!=49)
{
loop--;
continue;
}
putch(frame[loop]);
if(frame[loop]==13)
break;
}
flen=loop;
for(loop=0;loop<13;loop++)
{
if(loop<flen)
comp[loop]=frame[loop];
else
comp[loop]='0';
}
temp=loop;
for(loop1=0;loop1<flen;loop1++)
{
if (comp[0]=='0')
{
for(loop2=0;loop2<11;loop2++)
comp[loop2]=frame[loop2+1];
if(temp<=flen)
comp[loop2]=frame[temp++];
else
comp[loop2]='0';
quat[loop1]='0';
continue;
}
else
quat[loop1]='1';
if(loop1!=0)

{
if(temp<=flen)
comp[12]=frame[temp++];
else
comp[12]='0';
}
for(loop=1;loop<13;loop++)
{
if(comp[loop]=='1'&&generator[loop]=='1')
comp[loop-1]='0';
else if(comp[loop]=='0'&&generator[loop]=='0')
comp[loop-1]='0';
else
comp[loop-1]='1';
}
comp[12]='\0';
}
quat[loop1]='\0';
printf("\n\n component= %s",comp);
printf("\n quant = %s",quat);
printf("\n generator= %s", generator);
for(loop=0;loop<12;loop++)
frame[flen+loop]=comp[loop];
frame[flen=loop]='\0';
printf("\n CRC: %s",frame);
getch();  }