c - factorial of number using argument recursion(as in function call within argument list) -


my question regarding finding factorial of number using ternary operator in c. code below suggests using recursion, in not function definition, argument list. valid in c ?

[note : 0 factorial handled seperate piece of code]

the function prototype fact :

int fact(int); 

the definition :

int fact(num=(num>1)?num*fact(num-1):1) { return num; } 

my question is, recursion different instance of same function called within function, can true arguments ?

you want this:

int fact(int num) {     return num > 1 ? num*fact(num-1) : 1; } 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -