Find bitwise OR of all possible sub | Java program to find OR of all the sub - arrays ; function to return OR of sub - arrays ; Driver Code ; print OR of all subarrays
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 ( String args [ ] ) { int a [ ] = { 1 , 4 , 6 } ; int n = a . length ; System . out . println ( OR ( a , n ) ) ; } }