Odd numbers in N | CPP code to find the count of odd numbers in n - th row of Pascal 's Triangle ; Function to get no of set bits in binary representation of positive integer n ; Count number of 1 's in binary  representation of n. ; Number of odd numbers in n - th row is 2 raised to power the count . ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int countSetBits ( int n ) { unsigned int count = 0 ; while ( n ) { count += n & 1 ; n >>= 1 ; } return count ; } int countOfOddsPascal ( int n ) { int c = countSetBits ( n ) ; return pow ( 2 , c ) ; } int main ( ) { int n = 20 ; cout << countOfOddsPascal ( n ) ; return 0 ; }