user2962635
user2962635

Reputation: 151

Using c programming error

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.

Upvotes: 1

Views: 59

Answers (1)

Amadan
Amadan

Reputation: 198496

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.

Upvotes: 2

Related Questions