Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#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:

image text in transcribed

Sample Input/Output :

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine M. Ricardo, Susan D. Urban, Karen C. Davis

4th Edition

1284231585, 978-1284231588

More Books

Students also viewed these Databases questions