You are here:   HomeC Programming (Pratical)C Program Write a Program to Find the Greatest Between 3 Number
by Dinesh Thakur Category: C Programming (Pratical)

In this program user ask to convey that how to pass 2d array to a function. User define value in first instance for M=3, N=5. User also declare array type variable for storing the value. User input a message that prints a matrix for and then returns a value. Next move two functions are made for passing array like fstore, fretrieve and the loop statement also declares in the function for varying the condition. Nested loop statement is been implemented for the function. And in the last result is been displayed on the screen.

Problem statement:

This is C program that ask user to convey that how to pass 2d array value to function.

  1. Declare variables.
  2. Using functions.
  3. Vary loop statement.
  4. Display result on the screen.

Here is C source code for passing value to 2d array to function. The output of this program shown below. 

#include <stdio.h>

#define M 3
#define N 5
void fstore2D(int a[][N]);
void fretrieve2D(int a[][N]);
int main()
     int a[M][N];
     printf("Input Data in Matrix (%d X %d)\n", M, N);
     return 0;
     void fstore2D(int a[][N])
          int i, j;
          for (i = 0; i < M; ++i)
                  for (j = 0; j < N; ++j)
                       scanf("%d", &a[i][j]);
    void fretrieve2D(int a[][N])
         int i, j;
         for ( i = 0; i < M; ++i )
                  for ( j = 0; j < N; ++j)
                       printf("%6d ", a[i][j]);

C Program How to Pass Two Dimensional Array to a Function in C

Search Content

Advance Courses

Basic Courses

Advertise with Us