TCS NQT Question Solve | Programming Logic

TCS NQT Exam Updated Pattern 

Question 1:

Write a program that will print the sum of diagonal elements of a 10*10 matrix. The program will take total 100 numbers as input(10 numbers will be inputted per line and each number will be separated by a space).
For example, For the input provided as follows :
1 2 3 4 5 6 7 8 9 0
0 1 2 3 4 5 6 7 8 0
3 4 5 6 7 8 9 6 4 0
2 3 4 5 6 7 8 9 3 2
3 4 5 6 7 3 2 1 3 6
3 4 5 6 2 4 4 2 4 6
2 3 4 6 2 4 6 2 3 5
2 3 5 6 2 4 6 2 3 6 
2 4 6 2 1 4 3 3  5 2 
3 3 5 2 4  6 2 1 4 6

The program will provide the following output : 42

Answer :