The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+1 vote
117 views
void find(int x){
    static int i=10,y=0;
    y=y+i;
    for(i;i>0;i=i-10){
        if(x!=0)
        find(x-1);
        else{
            printf("%d",y);
        }
    }
}

What will be output printed for find(4)?

asked in Programming by Veteran (112k points) | 117 views
0
$50$
+1
@ankit
can u explain - why i value decrementing one time only?
0
pardon mam...I did mistake that time..you are right..it will not be decremented one time :p
0
ok,

that means i value will be decremented, but decremented after x value is 0.

why that?

is it because first iteration of for loop, is after all function call is completed?
0
yes
0

output: 50

final value of i : -40

0
50 is the right answer.
0
50 is a answer does i = I-10 because of tailed recursion will be executed after function call

Please log in or register to answer this question.

Related questions

0 votes
1 answer
3
+2 votes
2 answers
4
0 votes
0 answers
5
0 votes
1 answer
6
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,808 questions
54,481 answers
188,247 comments
74,517 users