bsc

Comprehensive codebase and cou...
Log | Files | Refs | README | LICENSE

APC-S-008.c (1628B)


      1 /*
      2  * Author  : Amit Dutta <amitdutta4255@gmail.com>
      3  * Date    : 12 Dec 2025
      4  * Repo    : https://github.com/notamitgamer/bsc
      5  * License : MIT License (See the LICENSE file for details)
      6  */
      7 
      8 /* Write a program to print the sum of two matrix as input given by the user. */
      9 /* Author: Amit Dutta, Date: 18-11-2025 */
     10 
     11 #include <stdio.h>
     12 
     13 int main()
     14 {
     15     int rows, cols, i, j;
     16     printf("Enter the number of rows and columns: ");
     17     scanf("%d %d", &rows, &cols);
     18 
     19     int a[rows][cols], b[rows][cols], c[rows][cols];
     20 
     21     printf("Enter the elements of matrix A (%d x %d): \n", rows, cols);
     22     for (i = 0; i < rows; i++)
     23         for (j = 0; j < cols; j++)
     24         {
     25             printf("Position %d%d: ", i, j);
     26             scanf("%d", &a[i][j]);
     27         }
     28     printf("\nMatrix A: \n");
     29     for (i = 0; i < rows; i++)
     30     {
     31         for (j = 0; j < cols; j++)
     32             printf("%d  ", a[i][j]);
     33         printf("\n");
     34     }
     35 
     36     printf("\nEnter the elements of matrix B(%d x %d): \n", rows, cols);
     37     for (i = 0; i < rows; i++)
     38         for (j = 0; j < cols; j++)
     39         {
     40             printf("Position %d%d: ", i, j);
     41             scanf("%d", &b[i][j]);
     42         }
     43     printf("\nMatrix B: \n");
     44     for (i = 0; i < rows; i++)
     45     {
     46         for (j = 0; j < cols; j++)
     47             printf("%d  ", b[i][j]);
     48         printf("\n");
     49     }
     50 
     51     for (i = 0; i < rows; i++)
     52         for (j = 0; j < cols; j++)
     53             c[i][j] = a[i][j] + b[i][j];
     54 
     55     printf("\nResult Matrix: \n");
     56     for (i = 0; i < rows; i++)
     57     {
     58         for (j = 0; j < cols; j++)
     59             printf("%d  ", c[i][j]);
     60         printf("\n");
     61     }
     62 
     63     return 0;
     64 }
© notamitgamer • Site Built: 2026-07-21 13:58:23 UTC • git-mirror commit: 1037f62 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror