Ask Question
26 October, 04:12

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

Select one:

True

False

+3
Answers (1)
  1. 26 October, 04:24
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers