Program 10 – ReversIt Function

Write a function reversit() which passes a string as a parameter and reverses the string using the procedure: First swap the first and the last character of the string, then the second and the second last character and so on.

Write a program to exercise reversit(). The program should get a string from the user. Call reversit() and print out the result. Use an input method that allows embedded blanks. Test the program with Napoleon’s famous phrase. “Able was I ere I saw Elba”.null

using namespace std;

void reverseit(char *s, int i, int j)
        char c;
        c = s[i];
        s[i] = s[j];
        s[j] = c;

int main()
    char *s;
    cout<<"Enter string to reverse: ";
    reverseit(s, 0, strlen(s)-1 );
    return 0;