Array and Strings – Arithmetic – Problem #2
IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive
Problem Statement
In this problem you will write a program that maintains a sorted list of distinct integers, by using a one- dimensional array. The following should be the input/output behavior of your program. Your program should also perfectly match the sample inputs and outputs given below. The program should first output a menu listing five options numbered 1 through 5, and ask the user to enter one of those options. See sample output. If the user enters a number other than 1-5, the program prompts the user to enter a valid option number and displays the menu again. If the user enters 1, the program asks the user for an integer. If the integer does not exist in the list, it is now inserted into the list, and the currently there are less than 100 elements in the list. The list should be sorted after the insertion. If the integer already exists in the list or there are already 100 elements in the list before insertion, the program displays an appropriate message (see sample outputs). After that, the menu of options is displayed again. If the user enters 2, the program asks the user to enter a range . The program should then delete all integers in the list that are between and , including both. At the end of deletion, the list should be sorted. If there is no integer in the list between and before deletion, a message should be displayed. Finally, the menu of options should be displayed again. If the user enters 3, the program asks for an input. The program then displays whether or not that integer exists in the list. This operation should not alter the list. Finally, the menu of options is displayed again. If the user enters 4, the program displays all the integers currently in the list, each in a new line. This operation should not alter the list. Note that the integers are displayed in sorted order. Finally, the the menu of options is displayed again. If the user enters 5, your program should terminate.