#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_SIZE 50
int main(){
int rcvDataSize,rcvDivSize;
char rcvData[MAX_SIZE], rcvDiv[MAX_SIZE], CRC[MAX_SIZE];
printf("Enter the data\n");
scanf("%s",&rcvData);
printf("Enter the divisor\n");
scanf("%s",&rcvDiv);
rcvDivSize = strlen(rcvDiv);
rcvDataSize = strlen(rcvData);
int i,j;
/**************************************************CRC*************************************************/
// initializing check_value
for(i=0;i<rcvDivSize;i++){
CRC[i]=rcvData[i];
}
do{
// check if the first bit is 1 and calls XOR function
if(CRC[0]=='1'){
for(j = 1;j < rcvDivSize; j++){
CRC[j] = ((CRC[j] == rcvDiv[j])?'0':'1');
}
}
// Move the bits by 1 position for the next computation
for(j=0;j<rcvDivSize-1;j++)
CRC[j]=CRC[j+1];
// appending a bit from data
CRC[j]=rcvData[i++];
}while(i<=rcvDataSize+rcvDivSize-1);
// loop until the data ends
// Append data with check_value(CRC)
for(i=rcvDataSize;i<rcvDataSize+rcvDivSize-1;i++){
rcvData[i]=CRC[i-rcvDataSize];
}
/******************************************************************************************************/
//print the result
printf("CRC is: %s\n",CRC);
printf("Final data: %s\n",rcvData);
return 0;
}
Unlock Success in Your MAKAUT Semester Exam with These Empowering Artificial Intelligence Suggestions! Elevate Your Learning Experience and Excel with Confidence.
Unlock Success in Your MAKAUT Semester Exam with These Empowering Mixed Signal Design Suggestions! Elevate Your Learning Experience and Excel with Confidence.
Unlock Success in Your MAKAUT Semester Exam with These Empowering Fiber Optic Communication Suggestions! Elevate Your Learning Experience and Excel with Confidence.
Unlock Success in Your MAKAUT Semester Exam with These Empowering Cyber Security Suggestions! Elevate Your Learning Experience and Excel with Confidence.
Transform your web design game with my CSS cheatsheet! Master the art of styling, dive into essential properties and selectors, and create visually stunning websites effortlessly. Whether…