Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8822929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:13:44+00:00 2026-06-14T06:13:44+00:00

Lets say if the input is 4 then the output should be all possible

  • 0

Lets say if the input is 4 then the output should be all possible 4 letter words with letters a to f. All the way from aaaa to ffff. How would I do this through the use of recursion?

My apologies for not including my attempt at the problem in my initial question. And some for you are wondering why I am using recursion instead of using a simpler method (such as a for loop for example) and the reason for this is that my prof wants us to use a for loop to solve this problem.

Here is my attempt at doing this:

void allPossiblilities(int n)
{
     char*result;
     if(Done(result))/*since the last possibility will be all f I am using that as my base case*/
     {
       printf("%s",result);
       return;
     }

 /*This is where the recursive part should go but I am totally lost as to what it should be*/
}

bool Done(result)/*This function just returns true if all the array's index are f*/
{
     int i;
     bool a=true;
     for(i=0;i<=n-1;i++)
        if(result[i]!='f')
           a=false;
}
     return a;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T06:13:45+00:00Added an answer on June 14, 2026 at 6:13 am

    I will give you a hint, to make you think:

    How many possibilities are for 4 digits and 10 possible numbers (0-9) base^digits = 10^4 = 10000 possible outputs 0000-9999, in your case they will base = 6 (A-F) and exp = 4 (4 positions) 6^4 = 1296 combinations.

    How are recursive functions made?
    They have 2 steps:

    • Basic Step: it’s the criteria or the condition when the function doesn’t call itself ( the final condition).

    • Recursive Step: It’s the criteria or the condition when the function calls itself, and the result of it should be nearer to the Basic Step.

    Example the famous factorial function, the basic step is the return of 1, and the recursive step is the second one.

    PD: I am trying to make you analyze the problem and get the solution by yourself, and giving you some tools.

    recursive example

    The code:

    #include <stdio.h>
    #include <stdlib.h>
    
    void recurs( int * s );
    void print( int * s );
    
    int main( void )
    {
        int a[] = { 0, 0, 0, 0 };
        print( a );
        recurs( a );
    
    }
    
    void recurs( int * s )
    {
        int i;
    
        /*Basic Case*/
        if( s[ 3 ] == 5 && s[ 2 ] == 5 && s[ 1 ] == 5 && s[ 0 ] == 5 ){
            print( s );
            printf( "\nAccomplisshed!\n" );
        }
    
        else{
            s[ 0 ] += 1;
            for( i = 0; i < 3; i++ ){
                if( s[ i ] == 6 ){
                    s[ i ] = 0;
                    s[ i + 1 ] += 1;
                }
            }
            print( s );
            recurs( s );
        }
    }
    
    /* This only prints. */
    void print( int * s )
    {
        int i; 
        printf( "    " );
        for( i = 3; i >= 0; i-- ){
            printf( "%c", ( s[ i ] + 65 ) );
        }
    }
    

    Part of the output:
    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say that input from the user is a decimal number, ex. 5. 2155
Lets say I have the following: $('input[rel]').jOverlay({ overlayId: #overlayID }); How can I dynamically
Lets say that you have a following simple application: <form action=helloServlet method=post> Give name:<input
Let's say that I expect a list of items from the standard input which
I created a simple program that lets you input a set of numbers, then
Lets say I have a method that is constantly receiving input every 10ms, adds
Lets say the input file is: Hi my name NONE Hi my name is
I can write an app that would copy all input from cin into a
Let's say that there are two PHP functions. function first() { $keyword = $this->input->post('keyword');
Lets say we have a table here, populated with the following data: acc_id1 acc_id2

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.