Question
This needs to be writtened in C: Part 1: You are required to open a file for input and read the data in that file
This needs to be writtened in C:
Part 1: You are required to open a file for input and read the data in that file into an array (named data). Use the variable size to count how many elements in the file. Create the file yourself in notepad and call it data.txt so that it has the following numbers in order: 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
Part 2: You are required to write the function called display which accepts an array, and a parameter named size which indicates the size of the array. This function prints the array (using the following format. List ==> # # # # # #) to the screen. A sample output is shown below. Display the original data array.
Part 3: You are required to write the function called reverse which accepts an array, and a parameter named size which indicates the size of the array. This function reverses the values in the array. In other words, flip the array from beginning to end. Display the flipped array using the function display created in part 2. A sample output is shown below. You are not allowed to create an extra integer array to solve this part, i.e., only the array that was sent from the main function is to be manipulated.
Part 4: You are required to write the function call countZerosOnes which counts the 0s and 1s from the array. The function MUST return the totalcount which will be the total of ones and zeros found. Display the number of 0s (numZeros) and number of 1s (numOnes). The number of 0s and 1s MUST be printed from main(). Also print the totalcount from main(). To be clear numZeros & numOnes will be passed to countZerosOnes by pointers and totalcount will be returned from countZerosOnes.
Input file: data.txt 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
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