
- Forum
- Programming Talk
- C and C++
- Help to solve these
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 ...
-
02-19-2011, 04:41 AM #1
- 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.
-
03-07-2011, 07:55 AM #2
- 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();
}

Reply With Quote





