-
What is the output of this program?
#include
using namespace std;
long fact (long p)
{
if (p > 1)
return (p * fact (p + 1));
else
return (1);
}
int main ()
{
long n = 6;
cout << n << "! = " << fact ( n );
return 0;
}
-
- 1
- 6
- segmentation fault
- compile time error
- None of these
Correct Option: C
As we have given in the function as p+1, it will exceed the size and so it arises the segmentation fault.