bsc

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

root / semester_1 / letusc / luc065.c

luc065.c (1092B)


      1 /* Write a program to find if a square matrix is symmetric.
      2 */
      3 
      4 /* Let Us C, Chap- 14 (Multidimensional Arrays), Qn No.: C(e) */
      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 mat[10][10], n, i, j;
     16     int is_symmetric = 1;
     17 
     18     printf("Enter the size of the square matrix (max 10): ");
     19     scanf("%d", &n);
     20 
     21     printf("Enter elements of the %dx%d matrix:\n", n, n);
     22     for (i = 0; i < n; i++)
     23     {
     24         for (j = 0; j < n; j++)
     25         {
     26             scanf("%d", &mat[i][j]);
     27         }
     28     }
     29 
     30     // Check for symmetry: mat[i][j] must equal mat[j][i]
     31     for (i = 0; i < n; i++)
     32     {
     33         for (j = 0; j < n; j++)
     34         {
     35             if (mat[i][j] != mat[j][i])
     36             {
     37                 is_symmetric = 0;
     38                 break;
     39             }
     40         }
     41         if (is_symmetric == 0)
     42             break;
     43     }
     44 
     45     if (is_symmetric)
     46         printf("\nThe matrix is Symmetric.\n");
     47     else
     48         printf("\nThe matrix is NOT Symmetric.\n");
     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