Wednesday, 7 October 2015

C PROGRAMMING -- SUM OF ALL ELEMENTS OF MATRIX

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

No comments:

Post a Comment