Write a C++ program that reads data from a file into an integer array that will
ID: 3647055 • Letter: W
Question
Write a C++ program that reads data from a file into an integer array that will hold a maximum of 100 components. Write the following void or value-returning functions:a. initialize all elements of the array to zero
b. read the data from a file and store it in the array
c. find the index of the component that holds the smallest value
d. find the average value stored in the array
e. print all of the elements in the array
f. print the index of the smallest value, the smallest value, the average and all of the components that are greater than the average
Explanation / Answer
#include #include #include #include using namespace std; const int SIZE = 100; void InitializeAlpha(int&, int ); void ReadFile(ifstream&, int alpha[], int SIZE); int main () { ifstream inData; ofstream outData; int alpha[SIZE]; int i; InitializeAlpha(alpha, SIZE); inData.open("data100.txt"); outData.open("results.txt"); while (inData) { ReadFile(inData, alpha, SIZE); } inData.close(); outData.close(); return 0; } void InitializeAlpha(int alpha[], int SIZE) { for(int i = 0; i alpha[i]; } }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.