C# program to calculate the NCR
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Program:
The source code to calculate the NCR is given below. The given program is compiled and executed successfully on Microsoft Visual Studio.
Output:
Explanation:
Here, we created a class Ncr that contains three static methods CalculateFactorial(), CalculateNcr(), and Main() method.
The CalculateFactorial() is used to calculate the factorial of the specified factorial and return to the calling method.
The CalculateNcr() is used to calculate the Ncr using the below formula.
The Main() method is the entry point for the program, Here we read the value of n and r and called the CalculateNcr() method that will return NCR that will be printed on the console screen.