/* addition of matrix */

# include <stdio.h>

void main ()

{

int a {2}{2} , b {2}{2} , c {2}{2} ;

int i , j ;

clrscr () ;

for ( i = 0 ; i < 2 ; i++ ) /* Input of first matrix */

{

for ( j = 0 ; j < 2 ; j++ )

{

printf ("\n Enter a number:") ;

scanf ("%d", & a {i}{j}) ;

}

}

for ( i = 0 ; i < 2 ; i++ ) /* Input of second matrix */

{

for ( j = 0 ; j < 2 ; j++ )

{

printf ("\n Enter a number:") ;

scanf ("%d", & b {i}{j}) ;

}

}

for ( i = 0 ; i < 2 ; i++ ) /* print first matrix */

{

for ( j = 0 ; j < 2 ; j++ )

printf ("%3 d", a {i}{j}) ;

printf ("\n") ;

}

for ( i = 0 ; i < 2 ; i++ ) /* print second matrix */

{

for ( j = 0 ; j < 2 ; j++ )

printf ("%3 d", b{i}{j}) ;

printf ("\n") ;

}

for ( i = o ; i < 2 ; i++ ) /* calculation of matrix */

{

for ( j = 0 ; j < 2 ; j++ )

{

c {i}{j} = a {i}{j} + b {i}{j} ;

}

}

for ( i = 0 ; i < 2 ; i++ )

{

for ( j = 0 ; j < 2 : j++ )

printf ("%3 d", c {i}{j}) ;

printf ("\n") ;

}

getch () ;

}

# include <stdio.h>

void main ()

{

int a {2}{2} , b {2}{2} , c {2}{2} ;

int i , j ;

clrscr () ;

for ( i = 0 ; i < 2 ; i++ ) /* Input of first matrix */

{

for ( j = 0 ; j < 2 ; j++ )

{

printf ("\n Enter a number:") ;

scanf ("%d", & a {i}{j}) ;

}

}

for ( i = 0 ; i < 2 ; i++ ) /* Input of second matrix */

{

for ( j = 0 ; j < 2 ; j++ )

{

printf ("\n Enter a number:") ;

scanf ("%d", & b {i}{j}) ;

}

}

for ( i = 0 ; i < 2 ; i++ ) /* print first matrix */

{

for ( j = 0 ; j < 2 ; j++ )

printf ("%3 d", a {i}{j}) ;

printf ("\n") ;

}

for ( i = 0 ; i < 2 ; i++ ) /* print second matrix */

{

for ( j = 0 ; j < 2 ; j++ )

printf ("%3 d", b{i}{j}) ;

printf ("\n") ;

}

for ( i = o ; i < 2 ; i++ ) /* calculation of matrix */

{

for ( j = 0 ; j < 2 ; j++ )

{

c {i}{j} = a {i}{j} + b {i}{j} ;

}

}

for ( i = 0 ; i < 2 ; i++ )

{

for ( j = 0 ; j < 2 : j++ )

printf ("%3 d", c {i}{j}) ;

printf ("\n") ;

}

getch () ;

}

## No comments:

## Post a Comment