Created
May 15, 2016 12:05
-
-
Save PaulChristmas/a4567119d51c742d9f9f920f663e822a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main (void) { | |
int n; | |
printf ("n = "); | |
scanf("%d", &n); | |
double B[n]; | |
int i; | |
for (i = 0; i < n; i++){ | |
printf ("\nB[%d] = ", i); | |
scanf("%lf", &B[i]); | |
} | |
/* initial values */ | |
double min = B[0], max = B[0]; | |
/* find minimum */ | |
for (i = 1; i < n; i++){ | |
if (B[i] < min){ | |
min = B[i]; | |
} | |
} | |
/* find maximum */ | |
for (i = 1; i < n; i++){ | |
if (B[i] > max){ | |
max = B[i]; | |
} | |
} | |
printf ("middle = (%lf + %lf)/2 = %lf", max, min, (max+min)/2); | |
getch(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment