Question: Code is to be done in C. Consider an array of characters char arr[] and max length n. Write a program with a recursive function

Code is to be done in C. Consider an array of characters char arr[] and max length ‘n’. Write a program with a recursive function that generates and prints all possible password combinations created using characters from the array ‘arr’ provided as command line input and having length, 1 <= length <= n, where ‘n’ is also a command line input

  • Create and submit only the main.c file

  • The printing and creation of the password should be done as a recursive function.

  • The input should be in command line and should be of type “./exeName M c1 c2 c3 N”

    • Here “exeName” is the name of the compiled executable

    • M is the number of allowable characters in the password, which will be followed after this. E.g., if allowable characters are ‘a’, ‘b’, ‘c’ then this M=3 and c1 = ‘a’, c2 = ‘b’ and c3 = ‘c’

    • N is the max length for the password

 

/* If we want ‘a’, ‘b’, ‘c’ and the max length of the password to be 2 */

// The way to run the code would be

./assignment7 3 a b c 2

// Output for the above run should be

a

b

c

aa

ab

ac

ba

bb

bc

ca

cb

cc

Step by Step Solution

3.39 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem we need to create a recursive function in C that generates all possible combinations of the given characters with varying length... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!