BCA

C LAB :PART A

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

C LAB : PART B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10

Write a C Program to find the trace of a square matrix using function

    
  /* Write a C Program to find the trace of a square matrix using function */



# include< stdio.h>
    #include< conio.h>
void main( )
{
int a[10][10], m,i,j, sum;
printf ("\n Enter order of the square matrix :") ;
scanf ("%d", &m);
printf ("\n Enter the matrix \n");
for( i=0; i< m;i++)
for ( j=0; j< m; j++)
scanf ("%d", &a[i ][ j ]);
/* loop to find trace of the matrix */
sum = 0;
for ( i=0; i< m; i++)
sum = sum + a[i ][ i ];
printf ("\n trace of the matrix = %d", sum);

getch();
}