1

I have this program and I am trying to output the value of n, but I am not getting any display. Program complies but no output.

    #include <stdio.h>

int rec(int x, int y)
{
    static int count = 0;
        if(x==0)
            return count;
            count++;
        if(x > y)
            rec(x - y, y);
        else
            rec(x,y-x);
        return count;
}

main(){
    int i=0, j=2, n;
        n = rec(i,j);
        printf("%d", n);
}

Need the value of N as output, program doesn't display anything.

1
  • 1
    When I ran it it output 0. Are you sure that's the code you're actually running? Commented Apr 14, 2014 at 0:52

1 Answer 1

2

Are you sure it doesn't? You do not output a newline, so it would be smushed against the next command line prompt, so it's kind of easy to miss.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.