Define a recursive print function that prints numbers from n to 0 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Define a recursive print function that prints numbers from n to 0

void print(int n) { if (n < 0) return; printf("%d", n); (n - 1); }

26th Apr 2020, 9:12 PM
Luis Valero Quintero
Luis Valero Quintero - avatar
2 Answers
- 2
void print(int n) { if (n< 0) return; printf ("%d", n); print (n-1); }
5th May 2021, 4:59 AM
Ashmitha Shekhar
Ashmitha Shekhar - avatar
- 6
Your question is, why it does not work, yes? "(n - 1);" has to be "print(n - 1)"
26th Apr 2020, 9:36 PM
Manu_1-9-8-5
Manu_1-9-8-5 - avatar