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

how we can make 3d venturing graphics on outer interface

4413


‎How to define structures? · ‎

869


Can variables be declared anywhere in c?

860


What does p mean in physics?

826


7-Given an index k, return the kth row of the Pascal's triangle. For example, when k = 3, the row is [1,3,3,1]. For reference look at the following standard pascal’s triangle.

2511


Can you tell me how to check whether a linked list is circular?

1103


What does it mean when the linker says that _end is undefined?

885


What does double pointer mean in c?

808


What is bubble sort in c?

853


Explain how do you print only part of a string?

955


What is wrong with this declaration?

859


Why is structure important for a child?

858


Explain what is meant by high-order and low-order bytes?

867


Are there namespaces in c?

821


What happens if you free a pointer twice?

842