2020-04-08 02:31:29 +03:00
|
|
|
#include <math.h>
|
2020-05-29 23:23:24 +03:00
|
|
|
#include <stdio.h>
|
2020-04-08 16:52:08 +03:00
|
|
|
#include <stdlib.h>
|
2017-07-16 05:44:01 +03:00
|
|
|
|
2020-04-08 02:31:29 +03:00
|
|
|
int main()
|
2016-10-18 17:17:54 +03:00
|
|
|
{
|
2020-05-29 23:23:24 +03:00
|
|
|
int a[10], n, i, j, temp;
|
|
|
|
float mean, median;
|
2020-04-08 02:31:29 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
printf("Enter no. for Random Numbers :");
|
|
|
|
scanf("%d", &n);
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
a[i] = rand() % 100;
|
|
|
|
}
|
|
|
|
printf("Random Numbers Generated are :\n");
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
printf("\n%d", a[i]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
printf("\nSorted Data:");
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
for (j = 0; j < n; j++)
|
|
|
|
{
|
|
|
|
if (a[i] < a[j])
|
|
|
|
{
|
|
|
|
temp = a[i];
|
|
|
|
a[i] = a[j];
|
|
|
|
a[j] = temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
{
|
|
|
|
printf("\n%d", a[i]);
|
|
|
|
}
|
2016-10-18 17:17:54 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
if (n % 2 == 0)
|
|
|
|
{
|
|
|
|
median = (a[n / 2] + a[(n / 2) - 1]) / 2;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
median = a[n / 2];
|
|
|
|
}
|
|
|
|
printf("\nMedian is : %f", median);
|
2020-04-08 02:31:29 +03:00
|
|
|
|
2020-05-29 23:23:24 +03:00
|
|
|
return 0;
|
2017-07-16 05:44:01 +03:00
|
|
|
}
|