Ask Question

In C++, arrays can be passed as parameters to a function either by value or by reference.

Select one:

True

False

+2
Answers (1)
  1. 19 February, 12:27
    0
    The statement written is True.

    Explanation:

    In C+ + you can pass arrays to function as parameters either by value or by reference.

    Following is the example of both cases.

    #include

    using namespace std;

    //array passed by value

    void printarray (int a[], int n)

    {

    for (int i=0; i
    cout<
    cout<
    }

    //array passed by reference

    void printarrayp (int * a, int n)

    {

    for (int i=0; i
    cout<
    cout<
    }

    int main () {

    int arr[100], size;

    cin>>size;

    for (int i=0; i
    cin>>arr[i];

    printarray (arr, size);

    printarrayp (arr, size);

    return 0;

    }

    Input:-

    6

    1 2 3 4 5 6

    Output:-

    1 2 3 4 5 6

    1 2 3 4 5 6

    In function printarray. The arrays is passed by value and in function printarrayp the array is passed by reference.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “In C++, arrays can be passed as parameters to a function either by value or by reference. Select one: True False ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers