Swapping element recursively

I'm trying to swap my elements recursive. For example, my program would scan the array from the left for upper case while scanning the right for lower case then it will swap both of them

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
26
27
28
29
30
31
  void swapElementR(char alphabets[], int size)
{
	int temp;
	int i = 0;
	int j = size - 1;
	
	if(size == 0)
	{
		return;
	}
	else 
	{
		if (alphabets[i] >= 'A' && alphabets[i] <= 'Z')
		{
			if (alphabets[j] >= 'a' && alphabets[j] <= 'z')
				{
					temp = alphabets[i];
					alphabets[i] = alphabets[j];
					alphabets[j] = temp;
					
					swapElementR(alphabets, size - 1);	  	  	  	  	  
				}				
			else 			
			--j;
		} 		
		else 		
		++i;		
	}		
	swapElementR(alphabets, size);	  	  	  
}  	     	
}


However, i am getting an infinite loop. Am i misundersdtanding any logic wrongly? I'm so confused because i just started learning
It's not an assignment. It's just an exercise for student to practice swapping element iteratively and recursively. Iterative is more straight forward IMO because i can just loop it. However, recursively needs base and general case to loop it hence it becomes more confusing for me :/
may i have your email instead?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void swap_char( char& a, char& b ) { const char temp = a ; a = b ; b = temp ; }

void partition_on_case( char cstr[], int sz )
{
    if( sz > 0 )
    {
        if( !std::isupper( cstr[0] ) ) partition_on_case( cstr+1, sz-1 ) ;

        else if( !std::islower( cstr[sz-1] ) ) partition_on_case( cstr, sz-1 ) ;

        else // cstr[0] is upper case, cstr[sz-1[ is lowercase
        {
            swap_char( cstr[0], cstr[sz-1] ) ;
            partition_on_case( cstr+1, sz-2 ) ;
        }
    }
}
may i have your email instead?

Why? Why not post publicly, so that you can get the most help?

Please be warned, gentleguy is a known troll. He regularly gives deliberately bad advice to beginners, to mess up their work, and he's admitted that he lies about the amount of experience he has. If you and he communicate privately, that gives him more opportunity to trick you, without anyone else being able to correct his bad advice.
@mikeyBoy

I've sent you my email via a PM.

This post isn't considered as public?
I've sent you my email via a PM.

Why would you do that? I've already indicated that a discussion in public is more helpful than one held privately via email. How on earth do you conclude from that that what I really want is to hold a private discussion via email?

This post isn't considered as public?

Of course it is. But a discussion held via email isn't.
I think i misunderstood your words and got threw off by the gentleguy who asked for my email. I thought you're personally asking me to send you my email via a PM.
Topic archived. No new replies allowed.