Last active
January 25, 2023 09:23
-
-
Save sabnamsp/ac4d8d5ae15bc552bad32fe597a01cae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
void main() | |
{ | |
int r1, r2, c1, c2; | |
int i,j; | |
int arr1[5][5], arr2[5][5]; | |
int sub_array[5][5]; | |
//First_Array | |
printf("\nEnter the row and column of 1st matrix: "); | |
scanf(" %d %d", &r1, &c1); | |
printf("\nEnter the elemets of 1st array: "); | |
for(i=0;i<r1; i++) | |
{ | |
for(j=0; j<c1; j++) | |
{ | |
scanf("%d", &arr1[i][j]); | |
} | |
} | |
printf("\nThe matrix of 1st array is: "); | |
for(i=0;i<r1; i++) | |
{ | |
printf("\n"); | |
for(j=0; j<c1; j++) | |
{ | |
printf("%d\t", arr1[i][j]); | |
} | |
} | |
//Second_Array | |
printf("\n\nEnter the row and column of 2nd matrix: "); | |
scanf(" %d %d", &r2, &c2); | |
printf("\nEnter the elements of 2nd array: "); | |
for(i=0;i<r1; i++) | |
{ | |
for(j=0; j<c1; j++) | |
{ | |
scanf("%d", &arr2[i][j]); //scanf for taking 2nd array's elements from user | |
} | |
} | |
printf("\nThe matrix of 2nd array is: "); | |
for(i=0;i<r1; i++) | |
{ | |
printf("\n"); | |
for(j=0; j<c1; j++) | |
{ | |
printf("%d\t", arr2[i][j]); | |
} | |
} | |
//Sub_Array | |
for(i=0;i<r1; i++) | |
{ | |
for(j=0; j<c1; j++) | |
{ | |
sub_array[i][j]=arr1[i][j]-arr2[i][j]; | |
} | |
} | |
printf("\n\nThe matrix of substruction of array is: "); | |
for(i=0;i<r1; i++) | |
{ | |
printf("\n"); | |
for(j=0; j<c1; j++) | |
{ | |
printf("%d\t", sub_array[i][j]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment