Find the remainder when N is divided by 4 using Bitwise AND operator | C ++ implementation to find N modulo 4 using Bitwise AND operator ; Function to find the remainder ; Bitwise AND with 3 ; Return x ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int findRemainder ( int n ) { int x = n & 3 ; return x ; } int main ( ) { int N = 43 ; int ans = findRemainder ( N ) ; cout << ans << endl ; return 0 ; }