Bitwise OR of all unordered pairs from a given array | C # program to implement the above approach ; Function to find the bitwise OR of all possible pairs of the array ; Stores bitwise OR of all possible pairs of [ ] arr ; Traverse the array [ ] arr ; Update totalOR ; Return bitwise OR of all possible pairs of [ ] arr ; Driver Code
using System ; class GFG { static int TotalBitwiseORPair ( int [ ] arr , int N ) { int totalOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { totalOR |= arr [ i ] ; } return totalOR ; } public static void Main ( String [ ] args ) { int [ ] arr = { 4 , 5 , 12 , 15 } ; int N = arr . Length ; Console . Write ( TotalBitwiseORPair ( arr , N ) ) ; } }