bsc

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

root / semester_1 / letusc / luc066.c

luc066.c (1098B)


      1 /* Write a program to add two 6 x 6 matrices.
      2 */
      3 
      4 /* Let Us C, Chap- 14 (Multidimensional Arrays), Qn No.: C(f) */
      5 
      6 /* This file is auto-generated by a bot. */
      7 /* This code is not compiled; it is for reference only. */
      8 
      9 
     10 #include <stdio.h>
     11 #include <stdlib.h>
     12 
     13 int main()
     14 {
     15     int mat1[6][6], mat2[6][6], sum[6][6];
     16     int i, j;
     17 
     18     // Initializing matrices with some values automatically 
     19     // to avoid asking user to enter 72 numbers.
     20     printf("Initializing two 6x6 matrices with sample data...\n");
     21     
     22     for (i = 0; i < 6; i++)
     23     {
     24         for (j = 0; j < 6; j++)
     25         {
     26             mat1[i][j] = i + j;       // Example data
     27             mat2[i][j] = i * j;       // Example data
     28         }
     29     }
     30 
     31     // Adding matrices
     32     for (i = 0; i < 6; i++)
     33     {
     34         for (j = 0; j < 6; j++)
     35         {
     36             sum[i][j] = mat1[i][j] + mat2[i][j];
     37         }
     38     }
     39 
     40     printf("\nSum of the two 6x6 matrices:\n");
     41     for (i = 0; i < 6; i++)
     42     {
     43         for (j = 0; j < 6; j++)
     44         {
     45             printf("%4d ", sum[i][j]);
     46         }
     47         printf("\n");
     48     }
     49 
     50     return 0;
     51 }
© notamitgamer • Site Built: 2026-09-05 01:53:16 UTC • git-mirror commit: c170d72 [view raw info]
Originally created with stagit • modified by notamitgamer
Forked from github.com/notamitgamer/git-mirror