Sum of diagonal elements in matrix in C Programming Tamil


#include<stdio.h>
#include<conio.h>
void main()
{
	int a[3][3],i,j,n=3,sum=0;
	clrscr();
	printf("\nEnter matrix elements :");
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	clrscr();
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
		   printf("\t%d",a[i][j]);
		}
		printf("\n\n");
	}
	for(i=0;i<n;i++)
	{
		sum=sum+a[i][i];
	}
	printf("\ndiagonal element  sum : %d",sum);
	getch();
}

Login To Download Source Code

Leave a Comment:

Login To Comment

List Of Programs


Goto Examples

Operators

Looping

Number Conversion

Pattern Design

Arrays

Matrix Examples

Sorting Examples

String Function

Change Case

String In C

Maths Functions

User Defined Functions

Recursive Functions

Pointer

Structure

File Concept

Calender Programming