having a problem with my function

Hi i have a problem. I am having a difficultly to change a function to recursive function.

This is my iterative function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
char swap(char charArray[], int col)
{   	
	char temp;
	
	for(int i = 0; i < col; i++)
	{
		for(int n = col; n > i; n--) 	 
		{
			if(!checkvowel(charArray[i]))
			{   
				if(checkvowel(charArray[n]))  
				{	 
					temp = charArray[i];
					charArray[i] = charArray[n];
					charArray[n] = temp;
				}
			
			}
		}	 
	}	
}


while this is my recursive function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
char swapR(char charArray[], int col,int n, int i)
{   	
	char temp;
	
	if(n > i)
	{	
		if(!checkvowel(charArray[i]))
		{
			if(checkvowel(charArray[n]))
			{	 
				temp = charArray[n];	
				cout << temp << endl;
				charArray[n] = charArray[i];
				charArray[i] = temp;
				
				return swapR(charArray, col ,n--, i++);	   
			}	 	 
		}
		n--;
	}
	else
	{
		i++;
	}
}


I have been trying for quite a while and still unable to get the output..
Any help will be appreciated. Thanks
Topic archived. No new replies allowed.