well i am new to this and i've got tough assignments to deal with. i worked hard on this one but my compiler shows errors. please help me
For circular function you can use a char pointer that points to the char array.
Whereas for reverse function you can copy the string stored in one array into another array reversely and displays that string.
Your output can be similar with the following:
Enter a string:
circular
String in circular order:
circular
ircularc
rcularci
cularcir
ularcirc
larcircu
arcircul
rcircula
String in reverse order:
ralucric
----------------------------------------------
#include<iostream.h>
#include<conio.h>
#include<string.h>
void circular(char[]);
void reverse(char[]);
const int size=10;
void main()
{
clrscr();
char str[size];
cout<<"Enter any word\n";
cin>>str;
cout<<"\nThe Circular of the word is :\n";
circular(str);
cout<<"\nThe Reverse of Word is : \n";
reverse(str);
getch();
}
void circular(char str[size])
{
char *sptr;
int i,j=0;
sptr=str;
while(*(sptr+1)!=0)
{
i=0;
sptr++;
j++;
cout<<sptr;
while(i<j)
{
cout<<str[i];
i++;
}
cout<<endl;
}
}
void reverse(char str[size])
{
int length = strlen(str);
for(int i=length-1; i>=0; i--)
cout<<str[i];
}