Exforsys
+ Reply to Thread
Results 1 to 2 of 2

Help to solve these

This is a discussion on Help to solve these within the C and C++ forums, part of the Programming Talk category; 1.Plz tell me to find the sum of diagonal elements of matrix 2.wap to raise power of all elements of ...

  1. #1
    Keshav frm nepal is offline Junior Member Array
    Join Date
    Feb 2011
    Answers
    1

    Help to solve these

    1.Plz tell me to find the sum of diagonal elements of matrix

    2.wap to raise power of all elements of an m*n matrix by 4.


  2. #2
    aravindhanarvi is offline Junior Member Array
    Join Date
    Mar 2011
    Answers
    1
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int i,j,n,a[30][30],sum=0;
    clrscr();
    printf("Enter the order for the matrix:");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
    for(j=0;j<n;j++)
    {
    scanf("%d",&a[i][j]);
    }
    }
    for(i=0;i<n;i++)
    {
    for(j=0;j<n;j++)
    {
    printf("%d\t",a[i][j]);
    }
    printf("\n");
    }
    for(i=0;i<n;i++)
    {
    for(j=0;j<n;j++)
    {
    if(i==j)
    {
    sum=sum+a[i][j];
    }
    }
    }
    printf("%d",sum);
    getch();
    }


Latest Article

Network Security Risk Assessment and Measurement

Read More...