SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
C program to find all combinations of a string
C program to find all combinations of a string
Output:
Enter the string to find all its combinations: abcd
All combinations of string 'abcd' are:
abcd bcd acd cd abd bd ad d abc bc ac c ab b a
Implementation:
#include
int main(void) { char *s; int sub,slen; int t; int i; s=(char*)malloc(sizeof(char)*1000); printf("Enter the string to find all its combinations:\n"); scanf("%s",s); slen=strlen(s); sub=pow(2,slen)-1; printf("All combinations of string '%s' are:\n"); while(sub) { t=sub; for(i=0;i
>=1; } sub--; printf("\n"); } return 0; }
PREVIOUS
NEXT
HOME