Examveda

What will be the output of the following C++ code?
#include <iostream>  
using namespace std;
int f(int &x, int c) 
{
   c  = c - 1;
   if (c == 0) return 1;
   x = x + 1;
   return f(x, c) * x;
} 
int main(int argc, char const *argv[])
{
	int a = 4;
	cout<<f(a,a);
	return 0;
}

A. 343

B. 336

C. 120

D. 840

Answer: Option A


Join The Discussion

Related Questions on Pointers and References in C plus plus

What is a pointer in C++?

A. A variable that stores the size of another variable

B. A variable that stores the address of another variable

C. A variable that stores a reference to another variable

D. None of the above