What will be the output of the following C++ code? [code] #include <iostream> using namespace std; long factorial (long a)

What will be the output of the following C++ code?
Code:
    #include <iostream>
    using namespace std;
    long factorial (long a)
    {
        if (a > 1)
            return (a * factorial (a + 1));
        else
            return (1);
    }
    int main ()
    {
        long num = 3;
        cout << num << "! = " << factorial ( num );
        return 0;
    }
A. 6
B. 24
C. segmentation fault
D. compile time error
 

Tìm kiếm

Back
Top