array as function parameter code example

Example 1: how to accept an array as function parameter in c

#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]);

    // passing 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]);
        }
    }
}

Example 2: js array as parameter

function myFunction(a, b, c) {//number of parameters should match number of items in your array
  	//simple use example
  	console.log("a: " + a);
  	console.log("b: " + b);
  	console.log("c: " + c);
}

var myArray = [1, -3, "Hello"];//define your array
myFunction.apply(this, myArray);//call function

Example 3: javascript function with array parameter

const args = ['test0','test1','test2'];
function call_me(param1, param2, param3){
  //
}
call_me.apply(this, args);