XOR of major diagonal elements of a 3D Matrix | C # program for the above approach ; Function to calculate Bitwise XOR of major diagonal elements of 3D matrix ; Stores the Bitwise XOR of the major diagonal elements ; Print the resultant Bitwise XOR ; Driver Code
using System ; class GFG { static void findXOR ( int [ , , ] mat , int N ) { int XOR = 0 ; for ( int i = 0 ; i < N ; i ++ ) { XOR ^= mat [ i , i , i ] ; XOR ^= mat [ i , i , N - i - 1 ] ; } Console . Write ( XOR ) ; } static public void Main ( ) { int [ , , ] mat = { { { 1 , 2 } , { 3 , 4 } } , { { 5 , 6 } , { 7 , 8 } } } ; int N = mat . GetLength ( 0 ) ; findXOR ( mat , N ) ; } }