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

Which control loop is recommended if you have to execute set of statements for fixed number of times?

824


What does typeof return in c?

646


What is the basic structure of c?

567


What oops means?

594


What is #include stdio h?

695






What is the difference between fread and fwrite function?

644


Differentiate between #include<...> and #include '...'

625


What is the use of clrscr?

609


When should you not use a type cast?

666


Write the program with at least two functions to solve the following problem. The members of the board of a small university are considering voting for a pay increase for their 10 faculty members. They are considering a pay increase of 8%. Write a program that will prompt for and accept the current salary for each of the faculty members, then calculate and display their individual pay increases. At the end of the program, print the total faculty payroll before and after the pay increase, and the total pay increase involved.

2658


Why we use stdio h in c?

594


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

753


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

608


What is the scope of static variable in c?

541


write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?

2417