adplus-dvertising
frame-decoration

Question

What will be the correct output for the given code snippet?
class maths
 {
     public int fact(int n)
     {
         int result;
         if (n == 2)
         return 1;
         result = fact(n - 1) * n;
         return result;
     }
 } 
 class Program
 {
     static void Main(string[] args)
     {            
         maths obj = new maths();
         Console.WriteLine(obj.fact(4));
         Console.ReadLine();
     }
 }

a.

24

b.

0

c.

12

d.

1

Answer: (c).12

Engage with the Community - Add Your Comment

Confused About the Answer? Ask for Details Here.

Know the Explanation? Add it Here.

Q. What will be the correct output for the given code snippet?

Similar Questions

Discover Related MCQs

Q. Which of these data types is used by operating system to manage the Recursion in Csharp?

Q. Which of these is not a correct statement?

Q. Which of these will happen if recursive method does not have a base case?

Q. What is Recursion in CSharp defined as?

Q. Choose the wrong statement from the given set of statements?

Q. What is vector in operator overloading?

Q. Choose the correct statement among the below mentioned statements:

Q. Correct method to define + operator is?

Q. Correct way to define operator method or to perform operator overloading is?

Q. Which statements are correct about operator overloading?

Q. Operators that can be overloaded are?

Q. Arrange the following overloaded operators in increasing order of precedence?

%, <<, &, /, +

Q. Which of following statements are correct in nature?

Q. Which of the following keyword is used to overload user defined types by defining static member functions?

Q. Choose the wrong statement about ‘INTERFACE’ in C#.NET?

Q. Access specifiers which can be used for an interface are?

Q. Which of these can be used to fully abstract a class from its implementation?

Q. Does C#.NET support partial implementation of interfaces?

Q. Which of the following is the correct way of implementing an interface addition by class maths?

Q. Choose the statements which makes interface different from classes?