VR Indian Wanderers Youtube RSS Feed
Learn with Vikas Suhag
Pass Multidimensional Arrays to a Function in C Language
Mar 06, 2022   Vikas Suhag

#include <stdio.h>

void displayNumbers(int num[2][2]);
int main() {
  int num[2][2];
  printf("Enter 4 numbers:\n");
  for (int i = 0; i < 2; ++i) {
    for (int j = 0; j < 2; ++j) {
      scanf("%d", &num[i][j]);
    }
  }

// pass multi-dimensional array to a function
displayNumbers(num);
  return 0;
}

void displayNumbers(int num[2][2])
{
  printf("Displaying:\n");
  for (int i = 0; i < 2; ++i)
    {
        for (int j = 0; j < 2; ++j)
        {
              printf("%d\n", num[i][j]);
        }    
    }
}


Leave a Comment

* Email will not be published.
All comments are only visible after approval.
Most Viewed articles
Travel Blog - VR Indian Wanderers
VR Indian Wanderers
Govt. Jobs Portal
Govt. Jobs Portal
Free Chart Maker
Make free animated Charts from .CSV
Search
Youtube Channel
Podcast
Subscribe to Email Updates
Connect With Us
VR Indian Wanderers Youtube RSS Feed
© 2024 Learn with Vikas Suhag. All Rights Reserved.