#include<iostream>
using namespace std;
int main()
{
char source[101],dest[101];
int pos = 0, j = 0;
cout<<"Enter string to be reversed"
<<"(please enter a maximum of 100 characters):"<<endl;
cin>>source;
while(source[pos]!= '\0')
{
pos = pos + 1;
}
for(--pos;pos>=0;dest[j++] = source[pos--]);
dest[j] = 0;
cout<<endl<<"The reversed string is :"<<endl<<dest<<endl;
return 0;
}
OUTPUT:
using namespace std;
int main()
{
char source[101],dest[101];
int pos = 0, j = 0;
cout<<"Enter string to be reversed"
<<"(please enter a maximum of 100 characters):"<<endl;
cin>>source;
while(source[pos]!= '\0')
{
pos = pos + 1;
}
for(--pos;pos>=0;dest[j++] = source[pos--]);
dest[j] = 0;
cout<<endl<<"The reversed string is :"<<endl<<dest<<endl;
return 0;
}
OUTPUT:
No comments:
Post a Comment