use to toggle sign in sequence .
ll toggle = 1 ; for ( int i = 1 ; i <= n ; i += 2 ) { ans = ans + nCr [ n ] [ i ] * pow ( cosTheta , n - i ) * pow ( sinTheta , i ) * toggle ; toggle = toggle * -1 ; } return ans ; }