Write a program for matrix diagonal element.

Write a program for matrix diagonal element.

Program:
#include<stdio.h>
main()
{
int n, i, j, x[10][10];

printf("Enter number =");
scanf("%d", &n);

for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
printf("Enter value for [%d][%d]=", i,j);
scanf("%d", & x[i][j]);
}
}

for(i=0; i<n; i++)
{
for(j=0; j<n; j++)
{
if(i==j)
printf("\t %d", x[i][j]);
}
}

}

Loading
Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Flying Twitter Bird Widget By ICT Sparkle