CNG140 Programming Assignment 1

Embed Size (px)

Citation preview

  • 8/12/2019 CNG140 Programming Assignment 1

    1/2

    Date handed out: Friday 7 March 2013

    Date submission due: Friday 21 March 2013

    Programming Assignment 1: IP Address AnalyzerPurpose:

    The main purpose of this programming assignment is to revise the topics covered in the first

    three weeks including fundamentals of C programming, conditional statements and

    repetitive statements.

    Description:

    In this project you will analyse the structure of an IP address (IPv4). You will need to use bitwise

    operations and practice different numbering systems. You will write a C program that

    accepts an IP address, as well as subnet-mask in in decimal format (base 10). The program

    will convert the IP address as well as the subnet mask to binary. The program will have options

    to show the class of the address and to calculate the number of available host addresses.

    Programming Requirements

    a. When you enter to the program your program will first prompt for the IP address and thesubnet mask as follows:

    Please enter the IP Address:

    192.10.10.2

    Please enter the Subnet Mask:

    255.255.255.192

    b. Then your program needs to display a menu to the user for asking about the analysis tobe performed. Please note that the program will keep on prompting the menu unless option

    6 is chosen.

    1. Convert IP address to binary2. Convert subnet mask to binary3. Specify the class of the IP address4. Specify the number of host addresses available5. Provide new IP Address and subnet mask6. Exit

    c. In case the user choses option 1, the IP address will be converted to binary by convertingeach octet individually. You are not allowed to use data structures such as arrays to store

    values for the conversion operation. For the given example your program will work as follows:

    Binary representation of IP Address:

    11000000.00001010.00001010.00000010

    d. In case the user choses option 2, the subnet mask will be converted to binary byconverting each octet individually. You are not allowed to use data structures such as arrays

    to store values for the conversion operation.For the given example your program will work as

    follows:

    Binary representation of Subnet Mask:

    11111111.11111111.11111111.11000000

    e. In case the user choses option 3, the binary format of the IP address will be used to specifythe class of the address using the following table.

    First octet of the IP adress Class

    Starts with 0 Class A

    MIDDLE EAST TECHNICAL UNIVERSITY, NORTHERN CYPRUS CAMPUS

    CNG140 C Programming Programming Assignment 1

  • 8/12/2019 CNG140 Programming Assignment 1

    2/2