Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

What is substring in c?

1146


Disadvantages of C language.

1061


In a switch statement, what will happen if a break statement is omitted?

1022


What is atoi and atof in c?

1040


What does typeof return in c?

1029


What is strcpy() function?

1096


Why c language is called c?

968


Explain what is a stream?

1047


Is swift based on c?

1062


Distinguish between actual and formal arguments.

1022


how can I convert a string to a number?

1045


List the different types of c tokens?

1019


Explain how do I determine whether a character is numeric, alphabetic, and so on?

1101


Is main an identifier in c?

1099


Explain the difference between #include "..." And #include <...> In c?

997