Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

After a program finishes executing, intermediate results are lost unless we save

ID: 3727344 • Letter: A

Question

After a program finishes executing, intermediate results are lost unless we save them somewhere. Frequently, this can be accomplished by writing the results to a file. For this problem, you must write a function saveData. • The function takes four arguments: the filename, an array of strings, an integer n which represents the number of values in the array, and the size of the array. The given array of strings has the following structure: The first n entries of the array will be values, and the n+1 entry will be a name ["value1", "value2", "value3","name"] • This function will convert the first n values of the array into double and compute their average. • Your function should then write to the file so that the result is in the following format: Name: name at n+1 position Avg: average of n numbers • If n=0, then print just the name and do not include the line with Avg: Name: first value from the array • If the input is not in a valid format the function should not write to the file.

Explanation / Answer

#include #include #include #include using namespace std; void saveData(string filename, string data[], int size, int nind) { ofstream out(filename.c_str()); out
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote