int main(void) { int i, n; float max, min, x; prn_info(); printf("Input n: "); scanf("%d", &n); printf("\nInput %d real numbers: ", n); scanf("%f", &x); max = min = x; for (i = 2; i <= n; ++i) { scanf("%f", &x); max = maximum(max, x); min = minimum(min, x); } printf("\n%s%11.3f\n%s%11.3f\n\n", "Maximum value:", max, "Minimum value:", min); return 0; }
main() /* De main-loop, hier gebeurt het, maar er worden functies gebruikt die in andere loops later in het programma staan */ { int i, n; float min, max, x; float minimum(float, float), maximum(float, float); void prn_info(void); prn_info(); /* informatie afdrukken */ printf("Geef n:"); scanf("%d", &n); printf("\nGeef %d real getallen:", n); scanf("%f", &x); min = max = x; for (i = 2; i <= n; ++i) { scanf("%f", &x); min = minimum(min, x); max = maximum(max, x); } printf("\n%s%.3f\n%s%.3f\n\n", "Minimum waarde:", min, "Maximum waarde:", max); }