Permutation of String in C and C++

Here you will get program for permutation of string in C and C++.

Permutation means all possible arrangements of given set of numbers or characters. For a string with n characters can have total n! arrangements. Take below example.

Permutation of String in C and C++

Here we are using backtracking method to find the permutation of a string. Watch below video to understand how to do this.

Below I have shared the code to implement this method in C and C++.

Program for Permutation of String in C

Output

Enter a string: abc
abc
acb
bac
bca
cba
cab

Program for Permutation of String in C++

Comment below if you have doubts or found any information incorrect in above tutorial.

Source: http://www.geeksforgeeks.org/write-a-c-program-to-print-all-permutations-of-a-given-string/

3 thoughts on “Permutation of String in C and C++”

Leave a Comment

Your email address will not be published. Required fields are marked *