Write a program to implement the checksum method The impleme

Write a program to implement the checksum method. The implementation has two parts: Calculating the checksum at the sender Verifying the checksum at the receiver Calculating the checksum at the sender Inputs: 4 data each consisting of 16-bit (binary) Output: Checksum of 16-bit (binary)

Solution

program #include<stdio.h>
#include<conio.h>
#include<math.h>
int sender(int b[10],int k)
{
int checksum,sum=0,i;
printf(\"\ ****SENDER****\ \");
for(i=0;i<k;i++)
{
sum+=b[i];
   printf(\"SUM IS: %d\",sum);
checksum=~sum;
   printf(\"\ SENDER\'s CHECKSUM IS:%d\",checksum);
   return checksum;
}
int receiver(int c[10],int k,int scheck)
{
int checksum,sum=0,i;
    printf(\"\ \ ****RECEIVER****\ \");
    for(i=0;i<k;i++)
   sum+=c[i];
   printf(\" RECEIVER SUM IS:%d\",sum);
   sum=sum+scheck;
   checksum=~sum;
   printf(\"\ RECEIVER\'s CHECKSUM IS:%d\",checksum);
       return checksum;
}
main()
{
    int a[10],i,m,scheck,rcheck;
clrscr();
    printf(\"\ ENTER SIZE OF THE STRING:\");
    scanf(\"%d\",&m);
    printf(\"\ ENTER THE ELEMENTS OF THE ARRAY:\");
    for(i=0;i<m;i++)
   scanf(\"%d\",&a[i]);
   scheck=sender(a,m);
   rcheck=receiver(a,m,scheck);
   if(rcheck==0)
   printf(\"\ \ NO ERROR IN TRANSMISSION\ \ \");
   else
   printf(\"\ \ ERROR DETECTED\");
getch();
}   

 Write a program to implement the checksum method. The implementation has two parts: Calculating the checksum at the sender Verifying the checksum at the receiv

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site