Write a C program to Print Square of Each Element of 2D Array Matrix
###### Posted by Samath
Last Updated: January 04, 2017

Write a C Program to Print Square of Each Element of 2D Matrix. Two-dimensional (2D) arrays are indexed by two subscripts, one for the row and one for the column.
Declare a local variable rating that references a 2D
array of int:

int[][] rating;

Code:

```#include<stdio.h>
#include<conio.h>

#define MAX_ROWS 3
#define MAX_COLS 4

void print_square(int[]);

void main(void) {
int row;
int num[MAX_ROWS][MAX_COLS] = { { 0, 1, 2, 3 },
{ 4, 5, 6, 7 },
{ 8, 9, 10,   11 } };

for (row = 0; row < MAX_ROWS; row++)
print_square(num[row]);
}

void print_square(int x[]) {
int col;
for (col = 0; col < MAX_COLS; col++)
printf("%d\t", x[col] * x[col]);
printf("\n");
}```

###### C Program to Check whether entered matrix is magic square or not
Samath | Jan 03, 2017
###### C program to find smallest element in array
Samath | Jan 02, 2017
###### C Program to Find Largest Element in Array
Samath | Jan 02, 2017
###### C Program to Search an element in Array
Samath | Jan 02, 2017
###### C Program to Insert an element in an Array
Samath | Jan 02, 2017
###### C program to delete an element from an array
Samath | Jan 02, 2017
###### C Program to Calculate Area of Square
Samath | Jan 02, 2017
###### C program that multiplies the matrix a by the matrix b and stores the result in the matrix c
Samath | May 04, 2016
###### C++ Magic Square
Samath | Jan 05, 2017
###### Square and Cube Class in C++
Samath | Jan 01, 2015
###### C Program to print table of n and square of n using pow() Function
Samath | Jan 02, 2017
###### Java program that calculates the square, cube, and fourth power of a number
Samath | Feb 08, 2021
###### Transposing an array using C++
Samath | Jan 07, 2021
###### C Program to Reverse an Array
Samath | Jan 02, 2017