Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in c++ format Read in a data file (the filename comes in via command-line arguments) with numbers on each line in the file and store

image text in transcribedin c++ format

Read in a data file (the filename comes in via command-line arguments) with numbers on each line in the file and store these values into a sorted array. Create the array of size 100 and use an array sentinel to keep track of the actual number of entries (will not exceed 100). As you read each value in, place it into the correct position in the sorted array. Then prompt the user for a number, and report back to the user if it is in the list and if so, what position in the list. Specifications: Use getline to read in each line from the file. Print out the name of the file you read in from command-line args. Create a function named insertIntoSortedArray that takes the array, number of entries currently in the array, and new value to be inserted as parameters. Inside the function insert the new value into the correct position in the sorted array. Return the new number of entries in the list. Use the following signature: int insertIntoSortedArray(int myArray[], int numEntries, int newValue) Print out the entire array each time after calling insertlntoSortedArray, displaying the values as a comma separated list. Print out the total number of entries in the array after reading in the file For example, Given a data file named dat.txt with the following values: 9 3 6

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

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

4. Show the trainees how to do it again.

Answered: 1 week ago