Write a factorial program using C.



Write a factorial program using C...

Answer / Andleeb Sayyed

Here is a simple recursive function that calculates the factorial of a given number n:
```c
long long factorial(int n) {n if (n == 0 || n == 1)
return 1;
else
return n * factorial(n - 1);
}n
```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

Is array name a pointer?

1 Answers  


to get a line of text and count the number of vowels in it

3 Answers   Satyam,


what type of language is C?

13 Answers   Microsoft,


what is difference between c and c++

4 Answers  


How can I implement opaque (abstract) data types in C? What's the difference between these two declarations? struct x1 { ... }; typedef struct { ... } x2;

2 Answers  


How can I remove the leading spaces from a string?

1 Answers  


Who is invented by c?

24 Answers   Infosys, Mphasis,


When should I declare a function?

1 Answers  


What is the difference between declaring a variable by constant keyword and #define ing that variable?

2 Answers  


what is event driven software and what is procedural driven software?

1 Answers  


Here is a neat trick for checking whether two strings are equal

1 Answers  


Difference between pass by reference and pass by value?

1 Answers   TCS, TISL,


Categories