Posts

Showing posts with the label Matrix

C Program to Multiply Two Matrix

  #include <stdio.h> #include <stdlib.h> #include <string.h> int main (){ // Initialising 1st Matrix system ( "clear" ); int m1 , n1 , m2 , n2 ; printf ( "No of Rows of 1st Matrix : " ); scanf ( " %d " , & m1 ); printf ( "No of Columns of 1st Matrix : " ); scanf ( " %d " , & n1 ); // Initialising the 2nd Matrix printf ( "No of Rows of 2nd Matrix : " ); scanf ( " %d " , & m2 ); printf ( "No of Columns of 2nd Matrix : " ); scanf ( " %d " , & n2 ); if ( n1 != m2 ) { printf ( "Can't Compute ... \n " ); // Checking n1=m2 } else { int matrix1 [ m1 ][ n1 ]; int matrix2 [ m2 ][ n2 ]; // Taking input of 1st Matrix printf ( " \n " ); printf ( "Enter the 1st Matrix : \n\n " ); for ( int i ...

C Program to Add two Matrix

  #include <stdio.h> #include <stdlib.h> int main (){ int m , n ; system ( "clear" ); printf ( "Enter the number of Rows : " ); scanf ( " %d " , & m ); printf ( "Enter the Number of Columns :" ); scanf ( " %d " , & n ); int arr_1 [ m ][ n ], arr_2 [ m ][ n ]; printf ( " \n First Matrix: \n " ); // Taking input of First Matrix . . . for ( int i = 0 ; i < m ; i ++ ){ for ( int j = 0 ; j < n ; j ++ ){ printf ( "a[ %d ][ %d ]" , i + 1 , j + 1 ); scanf ( " %d " , & arr_1 [ i ][ j ]); } } printf ( " \n Second Matrix: \n " ); // Taking input of Third Matrix . . . for ( int i = 0 ; i < m ; i ++ ){ for ( int j = 0 ; j < n ; j ++ ){ printf ( "b[ %d ][ %d ]" , i + 1 , j + 1 ); scanf ( " %d " , & arr_2 [ i ][ j ]); } } printf ( ...