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 8565007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:19:29+00:00 2026-06-11T17:19:29+00:00

I have a recursive program. When the printf is used in the function, it

  • 0

I have a recursive program. When the printf is used in the function, it outputs 123 and when used outside, it outputs 0123 .

#include <stdio.h>

fact(int);
int main()
{
    int x=3;
    fact(x);
    printf("\n");
    system("PAUSE");
}

int fact(int y)
{
    if (y > 0)
    {
         fact(y-1);
         printf("%d",y);  
    }
    //printf("%d",y);   
}   

I am not using both the printf at the same time . What difference does the location of this printf statement create?

  • 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-11T17:19:31+00:00Added an answer on June 11, 2026 at 5:19 pm

    fact(int) is called by following sequence,

    fact(3)–>fact(2)—>fact(1)—>fact(0)

    The last call is fact(0). According to the implementation of fact(int), when 0 is passed in, 0 is printed if printf() is used outsite. 0 is not printed if printf() is used inside.

    In fact, all the values passed into fact(int) is printed when printf() is used outsite.

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

Sidebar

Related Questions

I am currently trying to build a program where I have a recursive function
I have this code: #include <stdio.h> #include <stdlib.h> int func(int n0, int n); int
I have a program that does recursive calls for 2 billion times and the
I have created a concurrent, recursive directory traversal and file processing program, which sometimes
I have a recursive function working on a list, the function contains a loop
I have a recursive model like this: public class Node { public int Id
I have written a recursive Tree Function in pascal ( or delphi ) but
We have a fairly simple program that's used for creating backups. I'm attempting to
I have a problem for a university lab; Write a short program that outputs
I have written a C++ program that reads in a file and outputs the

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.