I am a newbie programmer and just started to teach myself C then decided to tackle some simple problems taken from the internet. Specifically with this one: Problem
And my solution is:
#include <stdio.h>
#include <math.h>
#include <float.h>
#include <limits.h>
int main() {
double min = DBL_MAX;
double max = DBL_MIN;
double n;
do {
scanf("%lf", &n);
if (n < 0.0001) {
break;
}
if (n > max) {
max = n;
}
if (n < min) {
min = n;
}
} while (n > 0.0000);
printf("Min: %.4f Max: %.4f\n", min, max);
return 0;
}
However, I need to run my program exactly as the input/output specified by the problem. For example, consider I am inputting in different lines:
1.1 1.2 1.3 3 6 9 11 -2 7
2.2
2.3 12
0
The program should output 12
as the max
and -2
as the min
, the program ends when the 0
was inputted.