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
Is main an identifier in c?
Why is sizeof () an operator and not a function?
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream
Explain a file operation in C with an example.
Explain how can you avoid including a header more than once?
What is difference between array and pointer in c?
Is that possible to store 32768 in an int data type variable?
What is the difference between printf and scanf )?
Write a C++ program to generate 10 integer numbers between - 1000 and 1000, then store the summation of the odd positive numbers in variable call it sum_pos, then find the maximum digit in this variable regardless of its digits length.
disply the following menu 1.Disply 2.Copy 3.Append; as per the menu do the file operations 4.Exit
What is huge pointer in c?
What is difference between union All statement and Union?
What does it mean when a pointer is used in an if statement?
What is strcpy() function?
write a program to rearrange the array such way that all even elements should come first and next come odd