deepak

#include <stdio.h>

// Function to calculate the factorial of a number
int factorial(int n) {
    if (n == 0 || n == 1) {
        return 1;
    } else {
        return n * factorial(n - 1);
    }
}

// Function to calculate the binomial coefficient
int binomialCoefficient(int n, int k) {
    return factorial(n) / (factorial(k) * factorial(n - k));
}

// Main function
int main() {
    int n, k;

    // Input values for n and k
    printf("Enter the value of n: ");
    scanf("%d", &n);
    printf("Enter the value of k: ");
    scanf("%d", &k);

    // Check if k is valid
    if (k < 0 || k > n) {
        printf("Invalid value of k. It should be between 0 and %d.\n", n);
    } else {
        // Calculate and display the binomial coefficient
        int result = binomialCoefficient(n, k);
        printf("The binomial coefficient C(%d, %d) is: %d\n", n, k, result);
    }

    return 0;
}