Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Create minmax.c
  • Loading branch information
doa14001 committed Mar 26, 2019
1 parent 709bda9 commit 70cc73a
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions minmax.c
@@ -0,0 +1,39 @@
#include <stdio.h>
#include <float.h>

int main() {
int n;
scanf("%d", &n);

float f;
float min, max;
if (n == 0) {
min = FLT_MAX;
max = -FLT_MAX;
}
else {
float listOfNum[n];
for (int i=0; i<n; i++) {
scanf("%f", &f);
listOfNum[i] = f;
}
min = listOfNum[0];
max = listOfNum[0];
for (int i =0; i<n; i++) {
if (listOfNum[i] > max) {
max = listOfNum[i];
}
if (listOfNum[i] < min) {
min = listOfNum[i];
}
}
}


// DO NOT EDIT BELOW THIS LINE
printf("The minimum value is: %.05f.\n", min);
printf("The maximum value is: %.05f.\n", max);

/* Let the OS know everything is just peachy. */
return 0;
}

0 comments on commit 70cc73a

Please sign in to comment.