Print all possible combinations of String in C.

#include<stdio.h>
#include<string.h>
int main()
{
    char str[20];
    int n, i, j, k=1, tmp;
    printf("Enter any string: ");
    scanf("%s",&str);
    n=strlen(str);
    for(i=0;i<n;i++){
    for(j=n-1;j>0;j--){
    tmp=str[j];
    str[j]=str[j-1];
    str[j-1]=tmp;
    printf("%2d : %s\n",k++, str);
    }
    }
    return 0;
}




No comments

Post your comments

Powered by Blogger.