Monday, 9 July 2018

Subtraction of matrix of order 2 * 2 in C

# 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

Featured post

Program to find maximum of three number using user define function in C++

A function can be define by the user as per the requirement of the user or programmer . To implement a user define function , a programmer ...