The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
61 views

How many times made easy is printed?
#include <stdio.h>
int main() {
       c(4);
return 0;
}
int c(int m){
    if (m>0){
        for(int i=1;i<3;i++){
            c(m-i);
            c(m-i-1);
            printf("madeeasy")
        }
    }
}

asked in Programming by (357 points)
edited by | 61 views
+1

is it 22 times?

+1

similar question https://gateoverflow.in/8060/gate2015-2-11, see the approach

1 Answer

+2 votes
Best answer

C(1) = for i=1, c(0) + c(-1) +pf() = 0+0+1=1 time madeeasy printed 

          for i=2, c(-1) + c(-2) + pf() = 0+0+1 =1 time madeeasy printed 

C(1) = 1+1 = 2

---------------------------------------------------------------------

C(2) = i=1, c(1) + c(0) +pf() = 2+0+1= 3 

          i=2, c(0) + c(-1) +pf() =0+0+1= 1 

C(2) = 3+1= 4

------------------------------------------------------------------------

C(3) = i=1, c(2) + c(1) + pf() = 4+2+1 = 7

          i=2, c(1) + c(0) +pf() = 2+0+1 =3

C(3) = 7+3 =10

-------------------------------------------------------------

C(4) = i=1, c(3) + c(2) + pf() = 10+4+1 =15

          i=2, c(2) + c(1) + pf() = 4+2+1 = 7

C(4) = 15+7 = 22 

 

Answer 22 times madeeasy printed 

answered by Active (4.1k points)
selected by

Related questions



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

42,514 questions
48,528 answers
155,013 comments
63,369 users