# C TUTORIAL
# C PROGRAMS
# C Array PROGRAMS
Matrix Programs in C
➤ How to Print 2D Array in C
➤ Store temperature of 2 Cities
➤ Pass MultiD Array to Function
➤ Largest-mallest in 2D Array
➤ Take and Print Matrix in C
➤ Matrix Addition in C
➤ Subtraction of Matrix in C
➤ Matrix Multiplication in C
➤ Transpose of Matrix in C
➤ Sum of Diagonal Elements
➤ Find Row-Sum Column-Sum
➤ Menu Driven Matrix Operations
# C PROGRAMS
# C Array PROGRAMS
Matrix Programs in C
➤ How to Print 2D Array in C
➤ Store temperature of 2 Cities
➤ Pass MultiD Array to Function
➤ Largest-mallest in 2D Array
➤ Take and Print Matrix in C
➤ Matrix Addition in C
➤ Subtraction of Matrix in C
➤ Matrix Multiplication in C
➤ Transpose of Matrix in C
➤ Sum of Diagonal Elements
➤ Find Row-Sum Column-Sum
➤ Menu Driven Matrix Operations
Many times we need to write a C program with deals with multidimensional arrays, and for code reusability, we are using functions. Sometimes we need to pass those arrays to the functions. Here we will see how to pass a multidimensional array to function in C.
#include<stdio.h>
void display(int n[2][2]);
int main()
{
int num[2][2], i, j;
printf("Enter 4 Elements of array[2][2]: ");
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
scanf("%d",&num[i][j]);
}
}
printf("Displaying values: ");
display(num);
// passing num[2][2] as num to display()
return 0;
}
void display(int n[2][2])
{
int i, j;
for(i=0;i<2;i++)
{
for(j=0;j<2;j++)
{
printf("%d ",n[i][j]);
}
}
}
Output:-
Enter 4 values: 10
15
20
25
Displaying values: 10 15 20 25
If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or do you find anything incorrect? Let us know in the comments. Thank you!
Examples on multidimensional Array in C