hello guys ! i have created a program just to understand how to return a value from using a recursive program

what it does it thati have have two variable i.e first and last
the value of first is zero and last is 10

not i want the function to continue until last ==to first
if not it would simply return the value of the last and decrement here is the code and the prob listed and yes i am noob

#include<conio.h>
#include "stdafx.h"
#include <iostream>
# define size 10;
int mergesort(int,int);
using namespace std;



int _tmain(int argc, _TCHAR* argv[])
{
    int first=0,last=10;

    //cout <<" enter the vlaues";

    //for(int i=0;i<10;i++)
    //cin>>arr[i];
    cout<<mergesort(first,last);
    system("pause");
    system("pause");
    return 0;
}

int mergesort(int first,int last,int mid)
{ int a=34343434;
   cout<<"mergesort called";
    if(first==last)
    {
                cout<<"its the end of the world";

                return a;
    }

if(first=!last)

{last--;
 cout<<"\n"<<last;
 mergesort(first,last,mid);
 return last;
}
return first;
}

here is the prob and plz tell me how to over come it

1>------ Build started: Project: merge sort, Configuration: Debug Win32 ------
1>Linking...
1>merge sort.obj : error LNK2019: unresolved external symbol "int __cdecl mergesort(int,int)" (?mergesort@@YAHHH@Z) referenced in function _wmain
1>C:\Documents and Settings\muqeet\My Documents\Visual Studio 2005\Projects\merge sort\Debug\merge sort.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\muqeet\My Documents\Visual Studio 2005\Projects\merge sort\merge sort\Debug\BuildLog.htm"
1>merge sort - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

i created this program in visual c++ 2005

Recommended Answers

All 4 Replies

First things first:
Does mergesort() take two or THREE parameters? You have it both ways.

this is not merge sort i was just testing a theory of mine or rather trying to understand it through experiment .
All this programdoes it that it recursivly displays counting in desending form that its

Ok then, now could you please answer thines01's question so we can help you further

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.