Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main(){
- int row,col;
- printf("Enter the Number of Rows : ");
- scanf("%d",&row);
- printf("Enter the Number of Columns : ");
- scanf("%d",&col);
- int a[row][col], b[row][col], c[row][col];
- //Storing Values
- printf("Enter the elements of A :-\n");
- for(int i=0; i<row; i++){
- for(int j=0; j<col; j++){
- printf("A[%d][%d]=",i+1,j+1);
- scanf("%d",&a[i][j]);
- }
- }
- printf("\nEnter the elements of B :-\n");
- for(int i=0; i<row; i++){
- for(int j=0; j<col; j++){
- printf("B[%d][%d]=",i+1,j+1);
- scanf("%d",&b[i][j]);
- }
- }
- //Matrix Addition
- for(int i=0; i<row; i++){
- for(int j=0; j<col; j++){
- c[i][j] = (a[i][j]+b[i][j]);
- }
- }
- //Displaying Result
- printf("\nResult of Addition:-\n");
- for(int i=0; i<row; i++){
- for(int j=0; j<col; j++){
- printf("%d ",c[i][j]);
- }printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement