Write a program to find the Factorial of a number



Write a program to find the Factorial of a number..

Answer / Raghvendra Kumar

```cppn#include <iostream>nnint factorial(int n) {n if (n == 0 || n == 1) return 1;n return n * factorial(n - 1);n}nnint main() {n int num;n std::cout << "Enter a number: ";n std::cin >> num;n std::cout << "Factorial of " num "":n std::cout << factorial(num) << std::endl;n return 0;n}n```

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C++ General Interview Questions

How would you stop a class from class from being derived or inherited?The constructer should not be Private,as object instantiation should be allowed.

15 Answers   Satyam,


What is the difference between a definition and a declaration?

1 Answers  


What do you mean by C++ access specifiers ?

1 Answers  


Explain the difference between using macro and inline functions?

1 Answers  


What does n mean in c++?

1 Answers  


why c++ is not called strictly d super set of c?

3 Answers   Satyam,


without if else statement can be written ah

0 Answers  


What does scope resolution operator do?

1 Answers  


How does the copy constructor differ from the assignment operator (=)?

1 Answers  


What is the difference between equal to (==) and assignment operator (=)?

1 Answers  


class base { public: int fun(int) {} }; class base2 { public: int fun(float) { } }; so here qustion is both function either function overloading or over riding;

4 Answers   Manhattan,


Explain "const" reference arguments in function?

1 Answers  


Categories