Question
using c++ Change the array of characters to an array of doubles. Make the changes necessary to search the array for a double number. Document
using c++
- Change the array of characters to an array of doubles.
- Make the changes necessary to search the array for a double number.
- Document if the name is found correctly. If not, get help to make it work properly to this program
#include
int searchList(char[], int, char); // function prototype
const int SIZE = 8;
int main() { char word[SIZE] = "Harpoon"; int found; char ch;
cout << "Enter a letter to search for:" << endl; cin >> ch;
found = searchList(word, SIZE, ch);
if (found == -1) cout << "The letter " << ch << " was not found in the list" << endl; else cout << "The letter " << ch << " is in the " << found + 1 << " position of the list" << endl;
return 0; }
//******************************************************************* // searchList // // task: This searches an array for a particular value // data in: List of values in an array, the number of // elements in the array, and the value searched for // in the array // data returned: Position in the array of the value or -1 if value // not found // //*******************************************************************
int searchList(char List[], int numElems, char value) { for (int count = 0; count <= numElems; count++) { if (List[count] == value) // each array entry is checked to see if it contains // the desired value. return count; // if the desired value is found, the array subscript // count is returned to indicate the location in the array }
return -1; // if the value is not found, -1 is returned }
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