Twitter Feed Facebook Google Plus Youtube

Adsense responsive

Recent Post below header

Wednesday 30 January 2013

C PROGRAM: TO CALCULATE SUM OF ELEMENTS BELOW MAIN DIAGONAL OF SQUARE MATRIX

CODING:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10][10],m,i,j,sum=0;
clrscr();
printf("Enter order of square matrix ");
scanf("%d",&m);
printf("Enter values of matrix\n");
for(i=1;i<=m;i++)
{
 for(j=1;j<=m;j++)
 {
  printf("Enter value of a[%d][%d] ",i,j);
  scanf("%d",&a[i][j]);
 }
}
for(i=1;i<=m;i++)
{
 for(j=1;j<=m;j++)
 {
  if(i>j)
  sum=sum+a[i][j];
 }
}
printf("\nSum of elements below main daigonal of matrix = %d",sum);
getch();
}


CODING


OUTPUT

For any query or suggestion please comment below...

No comments:

Post a Comment