Find bitwise OR of all possible sub | C # program to find OR of all the sub - arrays ; function to return OR of sub - arrays ; Driver Code ; print OR of all subarrays
using System ; class GFG { static int OR ( int [ ] a , int n ) { int ans = a [ 0 ] ; int i ; for ( i = 1 ; i < n ; i ++ ) { ans |= a [ i ] ; } return ans ; } public static void Main ( ) { int [ ] a = { 1 , 4 , 6 } ; int n = a . Length ; Console . Write ( OR ( a , n ) ) ; } }