type mismatch

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • piu15
    New Member
    • Oct 2015
    • 2

    type mismatch

    line 15:type mismatch in redclaration of 'merge'

    #include<stdio. h>
    #include<conio. h>
    void mergeSort(int x[],int lb,int ub)
    {
    int m;
    if(lb<ub)
    {
    m=(lb+ub)/2;
    mergesort(x,lb, m);
    mergesort(x,m+1 ,ub);
    merge(x,lb,m,ub );
    }
    }
    void merge(int x[],int lb,int m,int ub)
    {
    int temp[20],i,j,k;
    k=0;
    i=lb;
    j=m+1;
    while(i<=m && j<=ub)
    {
    if(x[i]<x[j])
    temp[k++]=x[i++];
    else temp[k++]=x[j++];
    }
    while(i<=m)
    temp[k++]=x[i++];
    while(j<=ub)
    temp[k++]=x[j++];
    k=0;
    for(i=lb;i<=ub; i++)
    x[i]=temp[k++];
    }
    void main( )
    {
    int x[20],i,n;
    printf("Enter the total number of elements: \n");
    scanf("%d",&n);
    printf("Enter the elements which to be sorted: \n");
    for(i=0;i<n;i++ )
    scanf("%d",&x[i]);
    mergesort(x,0,n-1);
    printf("After merge sorting elements are:\n");
    for(i=0;i<n;i++ )
    printf("%d ",x[i]);
    getch();
    }
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    You have to deide whether the function is mergesort or mergeSort.

    Other than that,you are calling merge before it is defined.

    Comment

    • piu15
      New Member
      • Oct 2015
      • 2

      #3
      THANKS......... ...
      It worked out!!!!!!!!!!! :) #thnkusomuch #onceagain :)

      Comment

      Working...