Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22016

why this recursive programis having garbage value even after assignment [closed]

$
0
0

The values in image appear from nowhere:

the values in image appear from nowhere

What are these values and if they are garbage values then why they are still present after assigning J the value. I am also attaching the source code.

int sum(int); void main(){        int a, b;        int j = 0;        printf("please enter the number to find the sum\n");         scanf("%d", &a);         j = a + 1;        printf("%d\n", j);        b = sum(j);        printf("the sum is %d", b);} int sum(int j) {    printf("jis %d\n", j);    int f;    if (j == 0)    {        printf("if cond\n");        return f;    }    else    {        j = j - 1;        printf("f up is %d\n", f);        f = j + sum(j);        printf("f dw is %d\n", f);        return f;    }}

Viewing all articles
Browse latest Browse all 22016

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>