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 do you mean by invalid pointer arithmetic?
Is c is a low level language?
Compare and contrast compilers from interpreters.
How can you find the day of the week given the date?
What is the purpose of ftell?
What are pointers?
ATM machine and railway reservation class/object diagram
What is the difference between a free-standing and a hosted environment?
What is array within structure?
How do you print an address?
c program for searching a student details among 10 student details
Are enumerations really portable?
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.
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
What is wrong in this statement? scanf(ā%dā,whatnumber);