/* 4-letter word unscrambling */ #include #include int main() { int i,j,k,l,sum=6; char str[5]; printf("Enter a 4-letter word or string : "); scanf("%s",str); if (strlen(str) == 4) { printf("The possible combinations of the given 4-letter word is shown."); for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) if (i != j) { for (k = 0; k < 4; k++) if ((k != i) && (k != j)) { l = sum - (i + j + k); printf("\n%c%c%c%c",str[i],str[j],str[k],str[l]); } } printf("\nTotal combinations = %d",4*3*2*1); } else printf("\nInvalid string. Length of the string must be 4-letters only "); return 0; } /* End of Main */