RANA MOHMEDSIDDIK
INTRO TO PROGRAMMING
FINAL PROJECT
MAURICIO MAURER
Â
#include <stdio.h>
Â
#define N 100
Â
intmain( )
  {                                                         Â
inti,j,number;Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
      float finalmedian,array[N],temporary;                                  Â
Â
printf("Please enter the number of elements \n");Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
scanf("%d", &number);Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
printf("Please input %d  the elements\n",number);                       Â
      for (i = 1; i<= number ;i++)                             Â
scanf("%f", &array[i]);Â Â Â Â
Â
   /* Now will perform the bubble Sorting */
for (i = 1 ; i<= number-1 ; i++)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
      {   Â
for (j = 1 ; j <= number-i ; j++)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
         {                                                  Â
             if (array[j] <= array[j+1])                            Â
             { /* Now we will perform the interchanging of the  values */
               temporary = array[j];                                    Â
               array[j] = array[j+1];                               Â
               array[j+1] = temporary;                                  Â
             }                                              Â
elsecontinue ;
         }                                                  Â
      }
Â
/*The process of  sorting will end here */
Â
/* Now we will calculate the median */
if ( number % 2 == 0)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
finalmedian = (array[number/2] + array[number/2+1])/2.0 ;
      else                                                  Â
finalmedian = array[number/2 + 1];Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
Â
   /* Finally we will display the median */
for (i = 1 ; i<= number ; i++)Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â
printf("%f ", array[i]);                             Â
printf("\n\nTheMedian of the number  is %f\n", finalmedian);                 Â
Â
return 0;
 }  Â
Â
Â
Â
Â
Â
Â