Skip to content

Instantly share code, notes, and snippets.

@PaulChristmas
Created May 15, 2016 12:05
Show Gist options
  • Save PaulChristmas/a4567119d51c742d9f9f920f663e822a to your computer and use it in GitHub Desktop.
Save PaulChristmas/a4567119d51c742d9f9f920f663e822a to your computer and use it in GitHub Desktop.
#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