Sail E0 Webinar
Question


What is the output of this program?


1.
#include
2.
using namespace std;
3.
long FACTORIAL (long a)
4.
{
5.
if (a > 1)
6.
return (a * factorial (a + 1));
7.
else
8.
return (1);
9.
}
10.
int main ()
11.
{
12.
long num = 3;
13.
cout
Options:
A .  6
B .  24
C .  segmentation fault
D .  compile time error
Answer: Option C

As we have given in the function as a+1, it will exceed the size and so it arises the segmentation fault.
Output:
$ g++ arg3.cpp
$ a.out
segmentation fault



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers