C - Interchange Elements of First and Last in a Matrix Across Columns Code Example

The code for Interchange Elements of First and Last in a Matrix Across Columns

void interchangeFirstLast(int mat[][n])
{
    // swap the elements between first and last columns
    for (int i = 0; i < n; i++) {
        int t = mat[i][0];
        mat[i][0] = mat[i][n - 1];
        mat[i][n - 1] = t;
    }
}
Code by IncludeHelp, on August 11, 2022 20:06

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.