1,966 views

2 Answers

Best answer
1 1 vote
$code(0)\rightarrow ME$ will print $0$ times

$code(1)\rightarrow{\color{Blue} {i=1}}$${\color{Purple} {----------\rightarrow }{code(0)}}$

                                   ${\color{Purple} {----------\rightarrow }{code(-1)}}$

                                   ${\color{Purple} {----------\rightarrow }{ME}}$

 

 

                            ${\color{Blue} {i=2}}$${\color{Purple} {----------\rightarrow }{code(-1)}}$

                                   ${\color{Purple} {----------\rightarrow }{code(-2)}}$

                                   ${\color{Purple} {----------\rightarrow }{ME}}$

 

So, for $code(1)$ $ME$ will print $2$ times

 

 

$code(2)\rightarrow{\color{Blue} {i=1}}$${\color{Purple} {----------\rightarrow }{code(1)}}$$\rightarrow$$ME$ prints $2$ times

                                   ${\color{Purple} {----------\rightarrow }{code(0)}}$

                                   ${\color{Purple} {----------\rightarrow }{ME}}$

 

 

                            ${\color{Blue} {i=2}}$${\color{Purple} {----------\rightarrow }{code(0)}}$

                                   ${\color{Purple} {----------\rightarrow }{code(-1)}}$

                                   ${\color{Purple} {----------\rightarrow }{ME}}$

 

So, for $code(2)$ $ME$ will print $4$ times

 

Similarly $code(3)$ will print $ME$ $10$ times

 

and $Code(4)$ will print $ME$ $22$ times
• selected by
1 1 vote

Ans is 22

Position:
Show:

Related questions

9 9 votes
3 3 answers
442
442 views
GO Classes asked Jun 17
442 views
What is the output of the following code?#include <stdio.h void update(int n, int *p) { if (n <= 0) return; *p = *p + n; update(n - 2, p); *p = *p + n; } int main() { int...
6 6 votes
2 2 answers
372
372 views
GO Classes asked Jun 17
372 views
What is the output of the following code?#include <stdio.h int fun(int n) { int x = n; if (n <= 0) return 0; x = x + 2; return x + fun(n - 2); } int main() { printf("%d",...
5 5 votes
4 4 answers
384
384 views
GO Classes asked Jun 16
384 views
What is the output of the following code?#include <stdio.h void g(int n); void f(int n) { if (n <= 0) return; printf("F%d ", n); g(n - 1); printf("f%d ", n); } void g(int...
6 6 votes
3 3 answers
376
376 views
GO Classes asked Jun 16
376 views
What is the output of the following code?#include <stdio.h void fun(int n) { static int x = 0; if (n == 0) return; x++; printf("%d:%d ", n, x); fun(n - 1); printf("%d:%d ...