0% found this document useful (0 votes)
28 views1 page

Experiment No.: 02 NAME: Pooja Gharat D.O.P: Roll No.: D.O.S: AIM: To Implement Checksum For Error Detection

This document describes a C++ program that implements checksum for error detection. The program takes in two 5-bit binary numbers as input, calculates their sum, takes the 1's complement of the sum, and adds it back to get the checksum. It stores each step's results in arrays c[], d[] to display the output at each stage.

Uploaded by

tansen1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views1 page

Experiment No.: 02 NAME: Pooja Gharat D.O.P: Roll No.: D.O.S: AIM: To Implement Checksum For Error Detection

This document describes a C++ program that implements checksum for error detection. The program takes in two 5-bit binary numbers as input, calculates their sum, takes the 1's complement of the sum, and adds it back to get the checksum. It stores each step's results in arrays c[], d[] to display the output at each stage.

Uploaded by

tansen1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

EXPERIMENT NO.

: 02
NAME: Pooja Gharat D.O.P:
Roll No.: D.O.S:
AIM: To Implement Checksum for error detection

#include<iostream.h>
#include<conio.h>
int main()
{
int a[5],b[5],c[5],d[5],carry=0,i;
cout<<"Enter the first number with 0's and
1's:\n";
for(i=0;i<5;i++)
{cin>>a[i];}
cout<<"Enter the second number with 0's and
1's:\n";
for(i=0;i<5;i++)
{cin>>b[i];}
for(i=4;i>=0;i--)
{
c[i]=(a[i]+b[i]+carry)%2;
carry=(a[i]+b[i]+carry)/2;
}
cout<<"sum of two bit no.is"<<endl;
for(i=4;i>=0;i--)
cout<<c[i]<<" ";
carry=0;
for(i=4;i>=0;i--)
{
if(c[i]==0)
d[i]=1;
else
d[i]=0;
}
cout<<endl<<"1's complement";
for(i=0;i<=4;i++)
cout<<d[i]<<" ";
for(i=4;i>=0;i--)
{
c[i]=(c[i]+d[i]+carry)%2;
carry=(c[i]+d[i]+carry)/2;
}
cout<<endl<<"result after adding 1's
complement and addition of two no.s"<<endl;
for(i=4;i>=0;i--)
cout<<c[i]<<"";
getch();
return 0;
}

You might also like