Submitted Questions

  • Calculate Primary and Secondary Diagonal

    Write an algorithm that calculates all the elements of rows and columns of a square matrix and calculate the total of primary and secondary diagonal.

    Kavya oleti

    • Jan 22nd, 2017

    If it is a square matrix order n
    Primary diagonal
    if(i==j)
    {
    sum+=a[i][j];
    }
    Secondary diagonal
    if(i==(n-1)-j)
    {
    sum+=a[i][j];
    }

    hema

    • Jan 3rd, 2015

    Tested Java code"java package testCode; public class SquareMatrix { public static void main(String[] args) { int [][] squarematrix = { { 1,1,1,10}, { 1,10,-1,2}...