Tuesday, October 13, 2009

rotational string

1. Rotate the String and display. For example, “SCOPE” “COPES” “OPESC” “PESCO”….
#include<stdio.h>
#include<string.h>
#include"conio.h"
int main()
{
int i,j=0;
char a[100]="scope";
//printf("enter the word\n");
//scanf("%s",a);
int length;
length=strlen(a);
while(j<length)
{
for(i=0+j;i<length;i++)
{
printf("%c",a[i]);
}
for(i=0;i<j;i++)
{
printf("%c",a[i]);
}
printf("\t");
j++;
}getch();
return 0;
}

No comments:

Post a Comment