Question: #1. Section 6.2 contains a C program to read a sorted array of integers from an input file and display the array. The program then

#1. Section 6.2 contains a C program to read a sorted array of integers from an input file and display the array. The program then allowed the user to search for an element in the array and displayed its position if it was found, and deleted a user specified element from the array. Finally, the program displayed the modified array.

Extend this program to do the following:

Add a method (function) called insert() which should insert an element in the appropriate place in the sorted array.

Modify the main() method (function) to allow the user the following options: Search for a key, Delete an element, Insert an element, or Exit. The main() method should loop infinitely until the user decides selects Exit. Obviously, after the user inserts an element or deletes an element, the main() method should display the modified array.

Be sure to use appropriate indentation and variable names in your program.

The code to extend:

#1. Section 6.2 contains a C program to read a sorted array

Sample Input/Output :

of integers from an input file and display the array. The program

main() toexample1.c #include FILE *fpt; int ary[25], i-e, searchKey, deletekey; fpt fopen("data20.txt", "r"; while (fscanf(fpt , "%d", &ary[1]) 1) void PrintArray (int aryl], int N int j printf ("Elements in the current array:In") for (j-0; j

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!