By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,471 Members | 722 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,471 IT Pros & Developers. It's quick & easy.

type mismatch

P: 2
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();
}
Oct 18 '15 #1
Share this Question
Share on Google+
2 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
You have to deide whether the function is mergesort or mergeSort.

Other than that,you are calling merge before it is defined.
Oct 19 '15 #2

P: 2
THANKS............
It worked out!!!!!!!!!!! :) #thnkusomuch #onceagain :)
Oct 19 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.