Rotations of a Binary String with Odd Value | CPP program to find count of rotations with odd value . ; function to calculate total odd decimal equivalent ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int oddEquivalent ( string s , int n ) { int count = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( s [ i ] == '1' ) count ++ ; } return count ; } int main ( ) { string s = "1011011" ; int n = s . length ( ) ; cout << oddEquivalent ( s , n ) ; return 0 ; }