i am tring to this way but answer is not write....thx...

#include<stdio.h>
#include<conio.h>
void main()
{
float a[10],m;
int i,j,n,t;
clrscr();
printf("how many number in array\n");
scanf("%d",&n);
printf("enter %d number\n",n);
for(i=1;i<=n;i++)
    {
    scanf("%f",&a[i]);
    }
for(i=1;i<=n;i++)
    {
    for(j=i+1;j<=n;j++)
        {
        if(a[i]>a[j])
            {
            t=a[i];
            a[i]=a[j];
            a[j]=t;
            }
        }
    }
if(n%2==0)
    {
    m=a[(n/2)+((n/2)+1)]/2;
    }
else
    {
    m=a[(n+1)/2];
    }
for(i=1;i<=n;i++)
    {
    printf("%.1f\t",a[i]);
    }
printf("\nmiedan value is %.1f",m);
getch();
}

Recommended Answers

All 2 Replies

The expression on line 29 resolves to m=a[n+1]/2;
I guess that is not the intention.
Try something like: m=(a[(n/2)]+a[(n/2)+1)])/2;

thx ddanbe...its work now....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.