2

Identify machines in same local network (Id-1053)

Just for Practice 2 Additional [3-Jan-2018 to 10-Apr-2018]

Bonus Practice Sheet Winter 2018 [17-Mar-2018 to 7-Apr-2018]

Program ID- 1248

Numeric addresses for computers on the international network, ‘Internet’ has four parts, separated by periods, of the form xxx.yyy.zzz.mmm where xxx , yyy , zzz , and mmm are positive integers. Locally, computers are usually known by a nickname as well.

Sample Data IP address Name
111.22.3.44 platte
555.66.7.88 wabash
111.22.5.66 green
0.0.0.0 none

A pair of computers are said to be in same locality when the first two components of the addresses are same. Given the details of some computers, design an algorithm and write a C program to display a list of messages identifying each pair of computers from the same locality. In the messages, the computers should be identified by their nicknames. In this example, the message to be displayed will be Machines platte and green are on the same local network.
For example, given IP address and nick name of machines as follows:

101.33.2.1 Atlas
101.33.56.80 Horizon
101.43.45.74 Pluto

Print ‘Machines Atlas and Horizon are on the same local network’.

Input Format
Number of computers ‘n’
IP address of the computer1 as a String
Nick names of the computer1 as a String
IP address of the computer2 as a String
Nick names of the computer2 as a String
….
IP address of the computer n as a String
Nick names of the computer n as a String

Output Format
For each pair of machines in the same local network, print:
Machines A and B are on the same local network (A and B are names of the respective machines)

 

Code

Please Comment Working if the code worked to you

If you have other working codes please comment the codes enclosing with <pre> and </pre> 🙂

Example: <pre> Your Code </pre>

C Code [By Chir Patel]

C++ Code

 

The Above Codes are for reference only. It doesn't mean everyone to directly copy/paste those codes.

 

Click Here to Leave a Comment Below 2 comments
Arani Ray - November 2, 2019

Wrong code.

Reply
Arani Ray - November 2, 2019

Reply

Leave a Reply:

This site uses cookies and by using the site you are consenting to this.