text: Bitwise OR of Bitwise AND of all subarrays of an array | C # program for the above approach ; Function to find the Bitwise OR of Bitwise AND of all subarrays ; Stores the required result ; Generate all the subarrays ; Store the current element ; Find the Bitwise OR ; Update the result ; Print the result ; Driver code
code: using System ; class GFG { static void findbitwiseOR ( int [ ] a , int n ) { int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int curr_sub_array = a [ i ] ; res = res | curr_sub_array ; for ( int j = i ; j < n ; j ++ ) { curr_sub_array = curr_sub_array & a [ j ] ; res = res | curr_sub_array ; } } Console . Write ( res ) ; } static void Main ( ) { int [ ] A = { 1 , 2 , 3 } ; int N = A . Length ; findbitwiseOR ( A , N ) ; } }