Input number in a matrix and print sum all the row of Matrices.
#include <stdio.h>
#include <conio.h>
void main ( )
{
int n1[3][3], i, j, s = 0;
clrscr ( );
printf ("\n\t\t\t Enter numbers in a matrix\n");
printf("\n\t\t\t________________________________________\n");
for ( i = 0; i < 3; i++ )
{
for ( j = 0; j < 3; j++)
{
printf("\n\t\t\t Position [%d] [%d]..:",i,j); scanf ("%d", &n1[i][j] );
}
}
clrscr ( );
printf("\n\n\n\n\t\t\t\t Matrix\n\t\t\t____________________________\n\n\t\t\t\t");
for ( i = 0; i < 3; i++ )
{
for ( j = 0; j < 3; j++ )
{
printf ("%3d ", n1[i][ j] );
}
printf ("\n\t\t\t\t");
}
printf("\n\n\t\t\t Sum of the rows of the Matrix\n\t\t\t_____________________________");
printf("\n\n\t\t\t\t");
for ( i = 0; i < 3; i++ )
{
s = 0;
for ( j = 0; j < 3; j++ )
{
s = s + n1[i][ j];
}
printf ("\n\n\t\t\t Sum of row no. [ %d ] = %d",i,s);
}
getch ( );
}
Click here to contact us
No comments:
Post a Comment