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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -