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 - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -