What is the output of the following code? [code] int fact(int n) { if(n == 0) return 1; return n * fact(n - 1); } int

Pham Quỳnh

New member
What is the output of the following code?
Code:
int fact(int n)
{
      if(n == 0)
        return 1;
      return n * fact(n - 1);
}
int main()
{
      int n = 1;
      int ans = fact(n);
      printf("%d",ans);
      return 0;
}
A. 0
B. 1
C. 2
D. 3
 

Tìm kiếm

Back
Top