StudyLover
  • Home
  • Study Zone
  • Profiles
  • Typing Tutor
  • Contact us
  • Sign in
StudyLover Program #26 (U3): Transpose and Symmetric Check
Download
  1. C Programming
  2. C Programming Practice
Program #25 (U3): Matrix Multiplication with Compatibility Check : Program #27 (U3): String Utilities without <string.h>
C Programming Practice

Task: Read a square matrix, compute its transpose, and compare with the original. Report whether the matrix is symmetric.

 
#include <stdio.h>

 
int main(void) {

    int n, a[50][50], t[50][50];

    printf("Enter n for an n x n matrix (<=50): ");

    if (scanf("%d", &n) != 1 || n <= 0 || n > 50) { printf("Invalid n.\n"); return 0; }

 
    printf("Enter matrix A (%d x %d):\n", n, n);

    for (int i = 0; i < n; ++i)

        for (int j = 0; j < n; ++j) scanf("%d", &a[i][j]);

 
    for (int i = 0; i < n; ++i)

        for (int j = 0; j < n; ++j) t[j][i] = a[i][j];

 
    printf("Transpose:\n");

    for (int i = 0; i < n; ++i) { 

        for (int j = 0; j < n; ++j) printf("%d ", t[i][j]); 

        printf("\n"); 

    }

 
    int symmetric = 1;

    for (int i = 0; i < n; ++i)

        for (int j = 0; j < n; ++j)

            if (a[i][j] != t[i][j]) { symmetric = 0; break; }

 
    printf("Symmetric? %s\n", symmetric ? "Yes" : "No");

    return 0;

}

 

 

Program #25 (U3): Matrix Multiplication with Compatibility Check Program #27 (U3): String Utilities without <string.h>
Our Products & Services
  • Home
Connect with us
  • Contact us
  • +91 82955 87844
  • Rk6yadav@gmail.com

StudyLover - About us

The Best knowledge for Best people.

Copyright © StudyLover
Powered by Odoo - Create a free website