Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Numeric addresses for computers on the international network Internet are com

ID: 3534467 • Letter: 1

Question

1. Numeric addresses for computers on the international network Internet

are composed of four parts, separated by periods, of the form

xx:yy:zz:mm

where xx,yy,zz, and mm are positive integers. Locally, computers are

usually known by a nickname as well. You are designing a program to

process a list of Internet addresses, identifying all pairs of computers from

the same locality. Create a structure type called address t with compo-

nents for the four integers of an Internet address and a fth component

in which to store an associated nickname of 16 characters. Your program

should read a list of up to 100 addresses and nicknames terminated by a

sentinel address of all zeros and a sentinel nickname.

Sample Data

111:22:3:44 platte

555:66:7:88 wabash

111:22:5:66 green

555:66:7:192 blue

0:0:0:0 none


The program should display a list of messages identifying each pair of

computers from the same locality | that is, each pair of computers with

matching values in the rst three components of the address. In the mes-

sages, the computer should be identied by their nicknames.

Example Message

Machines wasbash and blue are on the same local network.

Follow the messages by a display of the full list of addresses and nicknames.

Include in your program a scan address function, a print address func-

tion, and a local address function. Function local address should take

two address structures as input parameters and return 1 (for true) if the

addresses are on the same local network, and 0 (for false) otherwise.

Explanation / Answer

#include<iostream.h>

struct data

{

int x,y,z,m;

char name[16];

};

vooid main()

{

data mem[100];

int i;

for(i=0;i<100;i++)

{

cout<<"enter address of "<<i+1<<' network ";

cin>>mem[i].x>>mem[i].y>>mem[i].z;

cout<<"Enter nick name";

cin>>mem[i].name;

}

for(i=0;i<100;i++)

{

cout<<mem[i].x<<"."<<mem[i].y<<"."<<mem[i].z<<"."<<mem[i].m<<" <<mem[i].name;

cout<<" ";

}

}