Write a C++ program that prompts the user to input the string of length L and outputs the string in reverse order. Hint: Use pointers to accomplish the task.
Source Code:
#include<iostream>
using namespace std;
int main ()
{
int length;
cout<<"The length of
string:"<<endl;
cin>>length;
char ibrar[length];
char *s[length];
cout<<"String charachter
are:"<<endl;
for (int w=0;w<length;w++)
{
cin>>ibrar[w];
s[w]=&ibrar[w];
}
cout<<"Reversed order string
is:"<<endl;
for(int e=length;e>0;e--)
{
cout<<*s[e-1];
}
return 0;
}
0 Comments