Lab19C

Write a program called Lab19C that searches for a number in an array.
a. Write a bool function named search that receives 3 parameters: an int array, an int containing the length of the array, and an int number to search for. Return true if the number is ***** the array and false otherwise.
b. Write a void function called fillArray with the array as a parameter that uses a for loop to read the text file (Lab19C.txt) 20 times and place the values in the array.
c. In the main function, do the following:
i. Declare an array of 20 integers.
ii. Ask the user for a number to search for in the array
iii. Call fillArray sending the array as a parameter.
iv. Call the search function and send the array, the length of the array (20), and the search number as parameters.
v. Print the search number and the value returned by the function along with appropriate label to say if the number was found or not.

×
New Download