Recursive Function with Argument as array..!

Hi all..
I'm looking for the solution of the following problem..!

I need to write a recursive function that has as arguments an array of characters and two bounds on array indices. The function should reverse the order of those entries in the array whose indices are between the two bounds. For example, suppose that the array is :
a[5] = “abcde”;
and the bounds are 1 and 3. Then after the function is run the array elements should be “adcbe”.

Embed the function in a program and test it. To simplify grading, set up your character array as the whole alphabet:

char array[]=“abcdefghijklmnopqrstuvwxyz”;

And allow the user to specify bounds. Be sure to test our program using bounds that have both an even and an odd number of characters between them

Hope someone will help me with this.... Thanks in Advance.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I can't post a code, because the task looks like a homework.

The function you need to write is

// "a" is the array of characers
// "first" and "last" are the lower and upper bounds on the indices.
void reverse_interval(char *a, int first, int last) {
    reverse(a+first, a+last);

void reverse(char *first, char *last) {
    // check if the pointer to the first character is before the pointer to the last character
    // otherwise return from the function

    // swap the *first and the *last characters
    // call the function recursively with first+1 and last-1 parameters

#inlucde <iostream>

// the recursive function is very simple
void reverse(char *str, int beg, int end)
  // cancel condition
  if (beg >= end) return;
  //swap beg, end
  char tmp = str[beg];
  str[beg] = str[end];
  str[end] = tmp;
  // recursive call
  reverse(str, beg+1, end-1);

// nicer would be just to give two char pointers
void reverse(char *beg, char *end)
  // cancel condition
  if (beg >= end) return;
  //swap beg, end
  char tmp = *beg;
  *beg = *end;
  *end = tmp;
  // recursive call
  reverse(beg+1, end-1);

int main()
  // to specify the bounds by user:
  int beg, end;
  std::cout << "specify inner bound: ";
  std::cin >> beg;
  std::cout << "specify outer bound: ";
  std::cin >> end;
  char text[] = "abcdefghijklmnopqrstuvwxyz";
  reverse(text, beg, end);
  // to call reverse with two parameters:
  // reverse(text+beg, text+end);
  std::cout << text;
  return 0;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
To chip3d
Please do not give solution of homework questions.
Ahm, sorry...
sraziAuthor Commented:
Hi.. Everyone..
Actually I should be sorry at the first place and not chip3d, since I have asked a question which certainly is a homework for one of my friends, due to unawareness, rajeev_devin is quite right, but I still appreciate if someone atleast gives the Function code (as pallosp in this case) if not the full solution for the homework, since it'll help learn the subject fast or give some reading references or live example for the said subject.

And would like to know where to get paid assistance to complete the programming tasks and projects... ?

Thanks n Regards
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.