Contact Learn C
Copy Program Share Program

Program 252: Program to print Circularly Permuted String for n number of times

Program 252: Program to print Circularly Permuted String for n number of times

#include<stdio.h>
#include<string.h>
main()
{
 int i,j,permute;
 char str[100];
 printf("Enter a Sentence\n");
 gets(str);
 printf("Enter number of times it should circulate\n");
 scanf("%d",&permute);
 for(i=0;i<permute;i++)
 {
  char c=str[0];
  for(j=0;str[j]!='\0';j++)
  {
   if(str[j+1]!='\0')
   str[j]=str[j+1];
   else
   break;
  }
  str[j]=c;
  str[j+1]='\0';
 }
printf("%s",str);
printf("\n");
}
Explanation:

//Coming Soon

Output:

Program to print Circularly Permuted String for n number of times

Program to print Circularly Permuted String for n number of times






Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide