Thursday, March 4, 2021
Home C / C++ Binomial Coefficients in C++

Binomial Coefficients in C++

How we implement a logic to find out the binomial coefficients of an entered number by the user in C++?. Look at the below code:


    # include <iostream>
    using namespace std;
     
    int my_func(int x)    //defination
    {
     
        if (x==0)
        return 1;
     
        else 
     
            return x*my_func(x–1);
    }
     
    int bionomial_func(int power,int y)    //defination
    {
     
        cout<<” “;
        return my_func(power)/(my_func(y)*my_func(power–y));
         
    }
     
    void main()
    {
        int a;
        
        cout<<“enter binomial expression= “;    //enter the expression
     
        cin>>a;    
        
        cout<<“coefficients are”;
        cout<<endl;
     
        for(int i = 0; i <=a; ++i)
     
        {
            cout<<bionomial_func(a,i);
        } 
     
        cout<<endl;
    }

In the code for Binomial Coefficients we defined a function binomial_func()  in which we implemented the login of finding the binomial coefficients.

- Advertisment -

Most Popular

Android Webview Tutorial With Example | How to Use Webview in Android

Android Webview Tutorial With Example Have you seen an Android app displaying Web content using Webview. This Android Webview Tutorial is about integrating Webview using Android Studio....

Student Registration Project in PHP

In this Student Registration Project we are providing a form in simple html to the student and that form sends the data to "student.php"...

Java GUI Calculator Source Code

Here we have a Java GUI Calculator Source Code for you in which a Java GUI calculator has been created using "swing" and "awt". The calculator has...

Numeric Array in PHP

Numeric arrays can store numbers, strings and any object but their index will be represented by numbers. By default array index starts from zero....