logic for generating all the combinations of the any number
of given letters.
ex:::::::::
if a,b,c,d are given the o/p should be
abcd,dcba,dbac,bcad,................
4*3*2*1 combinations............

Answer Posted / ashok kannan

#include<stdio.h>
#include<conio.h>
#include<string.h>

char a[10];
int m;

void permute(int n,int i)
{
int j;
for(j=i;j<m;j++)
{
printf("%c",a[j]);

if(n!=0)
{
permute(n-1,i+1);
}
else
{
printf("%c\n",a[j]);
}

}

void main()
{
printf("enter the string to be permuted");
scanf("%s",a);
m=strlen(a);
permute(m,0);
}

Is This Answer Correct ?    2 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What do you mean by invalid pointer arithmetic?

645


Is c is a low level language?

574


Compare and contrast compilers from interpreters.

694


How can you find the day of the week given the date?

629


What is the purpose of ftell?

615






What are pointers?

642


ATM machine and railway reservation class/object diagram

4813


What is the difference between a free-standing and a hosted environment?

653


What is array within structure?

595


How do you print an address?

758


c program for searching a student details among 10 student details

1668


Are enumerations really portable?

602


write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.

1582


write a c program to print the next of a particular no without using the arithmetic operator or looping statements?

3201


What is wrong in this statement? scanf(ā€œ%dā€,whatnumber);

737