Sunday 9 September 2012

Array034

Input number in a matrix and print sum all the column 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 column 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[ j][i];
                }
                printf ("\n\n\t\t\t Sum of column no. [ %d ] = %d",i,s);
    }
    getch ( );
}
Click here to contact us

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...