Write a program to read from Week13File named “data.txt”, a series of integers. There will be at most 30 integers in the file. If the integer is even then write it to an array keeping count of how many integers are in the array.
a. After all of the even integers in the data are read into the array, write the contents of the array to the screen
b. In main prompt the user for an integer and read it in from the keyboard.
c. Write a linear search function that is passed the array, the number of elements in the array, and the number read in from the keyboard. The function should return the index of the element where the number is found or a -1 if not found.
d. After the function is called in main write a message to the screen “found” if the integer was found, if not, display “not found”.
a. Open Notepad or Visual Studio and create a file that is a list of integers, one per line, with the following 10 integers. Save your file as data.txt in the same folder as your .cpp file.
50
0
20
10
18
-5
15
22
34
-1
Comments
Leave a comment