A void function ReadArray that has an array parameter double
A void function ReadArray that has an array parameter double inArray[] and an integer parameter numValues that prints out a prompt telling the user to enter numValues double elements, reads in those values, and stores them in inArray.
A void function PrintArray that as an array parameter double dataArray[],an integer parameter numValues, and an integer value maxLine that prints out the first numValues of dataArray[] with maxLine values per line.
A double function minMax with an array parameter double dataArray[], an integer parameter numValues that is the size of the array dataArray[], a double parameter minVal that is a reference parameter that returns the minimum value of the array . The function should return the maximum value of dataArray[].
A void functions reverseArray with an array parameter double dataArray[], an integer parameter numValues that is the size of the array dataArray[] , and another array parameter double reversedArray[] that will return the values of dataArray[] in reverse order
These functions should be added to program (with necessary include and using statements and with any syntax errors corrected):
I need these fucntions printed before int main
Solution
#include <stdio.h>
void ReadArray(double* inArray,int numValues){
printf(\"Enter numValues : \\t\");
scanf(\"%d\",&numValues);
printf(\"Enter Array values : \\t\");
for(int i=0;i<numValues;i++){
scanf(\"%f\",&inArray[i]);
}
}
void PrintArray(double* dataArray, int numValues, int maxLine){
int j=1;
for(int i=0;i<numValues;i++){
printf(\"%f \",dataArray[i]);
if(j==maxLine){
printf(\"\ \");j=0;
}
j++;
}
}
double minMax(double* dataArray, int numValues, double minVal){
double max = minVal;
for(int i=0;i<numValues;i++){
if(dataArray[i]>max){
max = dataArray[i];
}
}
return max;
}
void reverseArray(double* dataArray, int numValues, double* reversedArray){
for(int i=0;i<numValues;i++){
reversedArray[numValues-i-1] = dataArray[i];
}
printf(\"Reversed Array Values are : \");
for(int i=0;i<numValues;i++){
printf(\"%f \",reversedArray[i]);
}
printf(\"\ \");
}
int main()
{
int numValues;
double inArray[numValues];
//1st question
ReadArray(inArray,numValues);
double temp[] = {5,9,88,77,33,22,11,43,55,21,19};
double reversedArray[11];
//2nd question
PrintArray(temp,9,2);
printf(\"\ \");
//3d question
printf(\"Max value is : %f\ \",minMax(temp,11,5));
//4th question
reverseArray(temp,11,reversedArray);
return 0;
}
![A void function ReadArray that has an array parameter double inArray[] and an integer parameter numValues that prints out a prompt telling the user to enter num A void function ReadArray that has an array parameter double inArray[] and an integer parameter numValues that prints out a prompt telling the user to enter num](/WebImages/4/a-void-function-readarray-that-has-an-array-parameter-double-980897-1761503511-0.webp)
![A void function ReadArray that has an array parameter double inArray[] and an integer parameter numValues that prints out a prompt telling the user to enter num A void function ReadArray that has an array parameter double inArray[] and an integer parameter numValues that prints out a prompt telling the user to enter num](/WebImages/4/a-void-function-readarray-that-has-an-array-parameter-double-980897-1761503511-1.webp)