Q : Write a ‘C’ program to find out sum of diagonal elements of a matrix using ‘C’.
Solution :
#include<stdio.h>
#include<conio.h>
#define MAX 3
void main()
{
int ar[MAX][MAX],i,j,r,c,sum=0;
clrscr();
for(r=0;r<MAX;r++)
{
for(c=0;c<MAX;c++)
{
printf("Enter
Number>> ");
scanf("%d",&ar[r][c]);
}
}
printf("\n\tOutput\n\n");
for(r=0;r<MAX;