Innovacx interview question

Can you write and explain the program about adding the diagonal elements in array (we should consider one element at once)