Answer to Question #22655 in C++ for rodea embradura

Question #22655
create a program that will generate the following output:

Enter a Word: Data Structure
Output: erutcurtS ataD
1
Expert's answer
2013-01-23T08:52:42-0500
#include<iostream>
using namespace std;

void rev(char *,char []);

void main()
{
char a[30];
char *ptr;
cout<<"Enter a word: ";
cin>>a;
ptr=a;
rev(ptr,a);
system("PAUSE");
}

void rev(char *ptr,char a[])
{
int k,c,i;
char b[30];
k=strlen(a);
c=k-1;
cout<<"Output: ";
for(i=c;i>=0;i--)
{
b[i]=*ptr;
ptr++;
}
b[k]='\0';
cout<<b<<endl;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS