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

Write a program that reads values (less than 100) from a data file and stores th

ID: 3621530 • Letter: W

Question

Write a program that reads values (less than 100) from a data file and stores the values in an array. Then it uses two functions to compute the maximum and the minimum values in the array. Finally, the maximum and minimum values are reported.

Explanation / Answer

#include #include int maximum(int a[10],int n) {int m,i; m=a[0]; for(i=0;i{ if(a[i]>m) m=a[i]; } return(m); } int minimum(int a[10],int n) {int m,i; m=a[0]; for(i=0;i{ if(a[i]} return(m); } void main() {FILE *fp;int max,min; int x[10],i;int n,val; fp = fopen("c:/rev.txt", "r"); /* write your file path,like "c:/rev" */ /* Check that the file is open */ if (fp==NULL){ printf("ERROR: cannot open the velocity file"); } else { printf(" How many data to be read"); scanf("%d",&n); /* Now that the file is open, loop until */ /* the max of the data is reached */ i=0; printf(" The array is--> "); while (i{fscanf(fp,"%d",&val); if(val
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