0

Is my user defined function okay?

Is it possible to call that function what is on declaration into the function? Can anyone explain the code? Specially line 11. https://code.sololearn.com/czKpWFxpTIw7/?ref=app

7th May 2022, 7:26 AM
KAZI FAISAL MAHMUD
KAZI FAISAL MAHMUD - avatar
1 Answer
+ 3
KAZI FAISAL MAHMUD Yes it is possible to call function inside itself. This is called recursion. Each time function will be call and parameter value will be change until you don't break function at some point. This code is running continuously till infinity because of count == 0 Do count <= 0 ---_---_---_--- You can get factorial of number using recursion. Factorial of 5 ------------ #include<stdio.h> int printFact(int count); int main () { printf("%d", printFact(5)); return 0; } int printFact(int count) { if(count <= 1) return 1; //printf ("Hello\n"); return count * printFact(count - 1); }
7th May 2022, 7:47 AM
A͢J
A͢J - avatar