Question
I made a c++ code that takes inputted float txt file and stores them into an array as first part of the program. Then the
I made a c++ code that takes inputted float txt file and stores them into an array as first part of the program. Then the program calls a function to use selection sort on the array. The program prompts the user to search for a value in the array. The program then uses binary search to find that value in the array and gives it back to the user, prompting for another value to find. So far I've gotten this
//inputs an float file int main() { int ARRAY_SIZE = 4; //array size is 100 max float numbers [ARRAY_SIZE]; int count = 0; //only loop once ifstream inputFile; //input file steam object
//Open the file inputFile.open("floatnumbers.txt");
//read the numbers from the file into the array while ( count < ARRAY_SIZE && inputFile >> numbers [count]) count++;
//close the file inputFile.close();
/*Display the numbers read cout << "The numbers are: *"; for (count = 0; count < ARRAY_SIZE; count++) cout << numbers [count] << " "; cout < cout << "Enter a value to search for: "; getline(cin, count); position = binarySearch(numbers, count); return 0; }//end main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started