0% found this document useful (0 votes)
71 views9 pages

EX P E RIM ENT N O. - 1: DCCN Filesem V-Shobhit Anand-858-Cs-10

The document describes three experiments related to IP addresses and error detection codes: 1. A program to determine if an IP address is Class A, B, C, D or E based on the first byte. 2. A program to translate a dotted decimal IP address into its 32-bit binary address. 3. A program to generate a Hamming code by calculating the parity bits and checking for errors in the received code.

Uploaded by

Rahul Dhaka
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views9 pages

EX P E RIM ENT N O. - 1: DCCN Filesem V-Shobhit Anand-858-Cs-10

The document describes three experiments related to IP addresses and error detection codes: 1. A program to determine if an IP address is Class A, B, C, D or E based on the first byte. 2. A program to translate a dotted decimal IP address into its 32-bit binary address. 3. A program to generate a Hamming code by calculating the parity bits and checking for errors in the received code.

Uploaded by

Rahul Dhaka
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 9

EXPERIMENTNO.

-1
AIM:WriteaC++ program to determineiftheIPaddress is in Class A, B,C, D, orE.

CODE:
//To determineiftheIPaddress is in Class A, B,C, D orE.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
voidmain()
{
clrscr();
inta[4],i=0;
cout<<"EnterTheIPaddress";
for(i=0;i<4;i++)
cin>>a[i];
cout<<"\nIPADDRESS:"<<a[0]<<"."<<a[1]<<"."<<a[2]<<"."<<a[3]<<"\n";
cout<<"TheIPaddress isinClass: ";
if(a[0]>=0&&a[0]<=127)cout<<"Cl
ass A";

if(a[0]>127 &&a[0]<191)
cout<<"Class B";
if(a[0]>191 &&a[0]<224)
cout<<"Class C";
if(a[0]>224 &&a[0]<=239)
cout<<"Class D";
if(a[0]>239)

cout<<"Class E";

DCCN FILESEM V–SHOBHIT ANAND-858-CS-10


getch();
}

OUTPUT

DCCN FILESEM V–SHOBHIT ANAND-858-CS-10


EXPERIMENTNO.-2
AIM: WriteaC++program to translatedotted decimalIPaddress into 32bit address.

CODE:
//Writeaprogram to translatedotted decimalIP address into 32 bit address
#include<iostream.h>
#include<conio.h>
voidmain()
{
clrscr();
inti,j,a[4],bin[8]={128,64,32,16,8,4,2,1};
cout<<"Entertheipaddress";
for(i=0;i<4;i++)

cin>>a[i];
cout<<"The ipaddress is:-"<<a[0]<<"."<<a[1]<<"."<<a[2]<<"."<<a[3]<<endl;
for(i=0;i<4;i++)
{
for(j=0;j<8;j++)
{
if(a[i]&bin[j])
cout<<1;
else
cout<<0;

}
cout<<".";
}

getch();

DCCN FILESEM V–SHOBHIT ANAND-858-CS-10


OUTPUT

DCCN FILESEM V–SHOBHIT ANAND-858-CS-10(Y)


EXPERIMENTNO.-3

AIM: Togenerate hamming code.

CODE:

#include<iostream.h>
#include<conio.h>
voidmain ()
{
inta0, a1, a2, a3, b0, b1,b2, b3, r0, r1, r2, s0, s1, s2, q0, q1, q2, q3;
cout<<"Entertheword\n";
cin>>a3>>a2>>a1>>a0;r0
= (a0+a1+a2)%2;

r1= (a1+a2+a3)%2;
r2= (a0+a1+a3)%2;
cout<<"Thecodeat senderis:
"<<a3<<a2<<a1<<a0<<r2<<r1<<r0;cout<<"\n Enterthecodeat
receiver:\n";cin>>b3>>b2>>b1>>b0>>q2>>q1>>q0;
cout<<"b3="<<b3<<",b2="<<b2<<",b1="<<b1<<",b0="<<b0<<",q2="<<q2<<",q1="<<q1<<",
q0="<<q0;
s0=(b2+b1+b0+q0) %2;
s1= (b3+b2+b1+q1) %2;
s2= (b1+b0+b3+q2) %2;

cout<<"\n"<<"s2="<<s2<<",s1="<<s1<<",s0="<<s0;
if(s2==0&&s1==0&&s0==0 )
cout<<"\n No Error";
elseif(s2==0&&s1==0&&s0==1)

cout<<"\n Error at q0";


elseif(s2==0&&s1==1&&s0==0)
cout<<"\n Error at q1";
elseif(s2==0&&s1==1&&s0==1)
cout<<"\n Error at b2";
elseif(s2==1&&s1==0&&s0==0)
cout<<"\n Error at q2";
elseif(s2==1&&s1==0&&s0==1)
cout<<"\n Error at b0";
elseif(s2==1&&s1==1&&s0==0)
cout<<"\n Error at b3";
elseif(s2==1&&s1==1&&s0==1)
cout<<"\n Error at b1";
getch();
clrscr();

DCCN FILESEM V–SHOBHIT ANAND-858-CS-10


OUTPUT

DCCN FILESEM V–SHOBHIT ANAND-858-CS-10

You might also like