Input 15 numbers. Arrange the numbers in ascending order and display the median of the same.
Write a program in C to accept 15 numbers, arrange these numbers in ascending order, display the median of the same.
#include< #define N 15 void main( ) { int i, j, n[N], t; printf("Enter %d integer values\n", N); for (i=0; i < N; i++) scanf("%d", &n[i]); for(i=0; i < N-1; i++) for (j=i+1; j < N; j++) if (n[i] > n[j]) { t = n[i]; n[i] = n[j]; n[j] = t; } printf("Median is %d\n", n[7]); getch( ); } |
---|
0 comments:
Post a Comment