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

1. Write a C program that prints out the max and min values of the data file inc

ID: 3687890 • Letter: 1

Question

1. Write a C program that prints out the max and min values of the data file included below. Instead of using computations within the main function like the problem in previous homework, use the programmer-define functions (reference functions with function prototypes) to solve it. You can choose anyone of the three data file structures (counter, sentinel, and neither counter/sentinel) to be included in your solution.

130.5 120 140

140.4 140.8 150.2

140 121 160.3

150 - 160.9 170

160.9 130.4 180

170 190.6 190

180 150.6 - 110

150 110 120.1

150.1 170.7 130

190 180 170

Explanation / Answer

working c code


#include<stdio.h>
#include<limits.h>

int main(){
FILE *fp = fopen("data.txt", "r");
double count;
double num,num1,num2;
double i;
double min = INT_MAX;
double max = INT_MIN;

for (i = 0; i < 11; i++)
fscanf( fp, "%lf %lf %lf", &num,&num1,&num2);
{   
if (num < min)
min = num;
if (num > max)
max = num;
if (num1 < min)
min = num1;
if (num1 > max)
max = num1;
if (num2 < min)
min = num2;
if (num2 > max)
max = num2;
}
fclose (fp);

printf("Of the given integers, the minimum value is %lf and the maximum value is %lf ", min, max);
return 0;
}

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