C++ programming language part- 81 Programming Logic and Technique:
Programming
Logic and Technique:
{ char string1[10], string2[10]; //array of size 10 defined
int i,j;
display
"type a string "
accept string1;
for(i=0;string1[i]!='\0';i++);
i--;
display
" The reverse string is ";
for(j=0;i>=0;j++,i--)
{
string2[j]=string1[i];
}
string2[j]='\0';
display<
Program
Ex_19_1
//reverse
string (arraydemo.c)
#include
#include
void main()
{
clrscr(); // To clean the screen
char
a1[10],a2[10];//array of size 10 defined
int i,j;
cout<<"type
a string "<<"\n";
cin>>a1;
for(i=0;a1[i]!='\0';i++);
i--;
cout<<"
The reverse string is "<
for(j=0;i>=0;j++,i--)
{
a2[j]=a1[i];//
}
a2[j]='\0';
cout<
}