A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

Write a program to reverse String using array to pass as argument

Passing array as argument of a function:

Program code:



#include<iostream>
using namespace std;
class Reverse
{
    public:
        char inputstring(char f[], int n)
        {
            int i;
            cout<<"Input the string:\n";
            for(i=0;i<n;i++)
            {
                cin>>f[i];
            }
        }
        char outputstring(char f[],int n)
        {
            int j;
            cout<<"The output string is:";
            for(j=--n;j>=0;j--)
            {
                cout<<f[j];
            }
        }
};
int main()
{
    int i,j;
    char f[10];
    Reverse o;
    o.inputstring(f,5);
    o.outputstring(f,5);
    return 0;
}



Sample output:


LEARN TUTORIALS

.

.