Question
The program needs to be done in C++ using arrays and functions. Create a program that will read values from a file called Lab8.dat (posted
The program needs to be done in C++ using arrays and functions.
Create a program that will read values from a file called Lab8.dat (posted on Canvas) and store it into an array using a function other than main. The number of values in the file is less than 300 and all the values are whole numbers. The actual number of values stored in the file should be returned to the function call.
Your program should contain another function that accepts the array, the number of values in the array, and a whole number. This function should use a loop to count how many values in the array are evenly divisible by the whole number and return this count to the function call. The loop should not contain more than 3 arithmetic operators (++ and += count as arithmetic operators, but = does not).
The main function should call the function to read the data from the file. Next, ask the user to enter a whole number between 2 and 20 (you may assume the user enters a correct value). This whole number is the value to divide each element in the array. Next, call the function to determine how many values in the file are evenly divisible by the entered whole number and output the returned count. The message should be something like
35 of the 189 values in the file were evenly divisible by 19. with the underlined values replaced by the your calculated values and the users input.
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