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
What is substring in c?
Disadvantages of C language.
In a switch statement, what will happen if a break statement is omitted?
What is atoi and atof in c?
What does typeof return in c?
What is strcpy() function?
Why c language is called c?
Explain what is a stream?
Is swift based on c?
Distinguish between actual and formal arguments.
how can I convert a string to a number?
List the different types of c tokens?
Explain how do I determine whether a character is numeric, alphabetic, and so on?
Is main an identifier in c?
Explain the difference between #include "..." And #include <...> In c?