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
Which control loop is recommended if you have to execute set of statements for fixed number of times?
What does typeof return in c?
What is the basic structure of c?
What oops means?
What is #include stdio h?
What is the difference between fread and fwrite function?
Differentiate between #include<...> and #include '...'
What is the use of clrscr?
When should you not use a type cast?
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.
Why we use stdio h in c?
What are the difference between a free-standing and a hosted environment?
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?
What is the scope of static variable in c?
write a c program thal will find all sequences of length N that produce the sum is Zero, print all possible solutions?