- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Sum of squares of binomial coefficients in C++

The binomial coefficient is a quotation found in a binary theorem which can be arranged in a form of pascal triangle it is a combination of numbers which is equal to nCr where r is selected from a set of n items which shows the following formula

nCr=n! / r!(n-r)! or nCr=n(n-1)(n-2).....(n-r+1) / r!

The sum of the square of Binomial Coefficient i.e
(_{n}C_{0})^{2} + (_{n}C_{1})^{2} + (_{n}C_{2})^{2} + (_{n}C_{3})^{2} + ……… + (_{n}C_{n-2})^{2} + (_{n}C_{n-1})^{2} + (_{n}C_{n})^{2}

Input :n=5 Output:252

### Explanation

In this program first we have to find the binomial coefficient of r which is selected from n set then we have to square each coefficient and sum them we can derive a formula from the above equation or use of factorial function of each digit to get a sum so we will fall or factorial function in which we will pass and r for a given equation and then add it then we get the solution

### Example

#include <iostream> using namespace std; int fact(int n){ int fact = 1, i; for (i = 2; i <= n; i++){ fact *= i; } return fact; } int main(){ int n=5; int sum = 0; int temp=0; for (int r = 0; r <= n; r++){ temp = fact(n)/(fact(r)*fact(n-r)); sum +=(temp*temp); } cout<<sum; return 0; }

### Output

252

- Related Questions & Answers
- Find sum of even index binomial coefficients in C++
- C program for Binomial Coefficients table
- Sum of squares of Fibonacci numbers in C++
- Sum of series with alternate signed squares of AP
- Sum of squares of first n natural numbers in C Program?
- Difference between sum of the squares of and square of sum first n natural numbers.
- C++ Program for Sum of squares of first n natural numbers?
- Python Program for Sum of squares of first n natural numbers
- Sum of squares of the first n even numbers in C Program
- Sum of perimeter of all the squares in a rectangle using JavaScript
- Is a number sum of two perfect squares in JavaScript
- Minimize the sum of squares of sum of N/2 paired formed by N numbers in C++
- Java Program to calculate Sum of squares of first n natural numbers
- Memory representation of Binomial Heap in C++
- Minimum number of squares whose sum equals to given number n