Reversing the input text.
Example
If user enters “This is my program.” You should output “program my is This”
#include < iostream . h >
using namespace std;
int main()
{
char a[20];
cout < < "please enter your string" < < endl;
cin.getline(a,20);
int b,c;
b=19;
c=b;
int g;
for(int i=b;i > = 0; i--)
{
if(a[i]==' ')
{
g=i+1;
for(int j=g;j < =c; j++)
{
cout < < a[j];
}
cout < < " ";
c=i -1;
}
}
return 0;
}
Example
If user enters “This is my program.” You should output “program my is This”
#include < iostream . h >
using namespace std;
int main()
{
char a[20];
cout < < "please enter your string" < < endl;
cin.getline(a,20);
int b,c;
b=19;
c=b;
int g;
for(int i=b;i > = 0; i--)
{
if(a[i]==' ')
{
g=i+1;
for(int j=g;j < =c; j++)
{
cout < < a[j];
}
cout < < " ";
c=i -1;
}
}
return 0;
}
No comments