Post a New Question

college

posted by .

Write a C++ program to fill an array with 6 numbers, and then reverse the values of this array.
Note: By using a function with two parameters with the name of the array and the size of this array.

  • college -

    If you need to interchange the values contained in two array element, you need to have a temporary storage.

    Assuming the array contains integers ("numbrs"), it would look something like this:

    int ar[6];
    .... read in values to ar[0] - ar[5].
    ...
    exchange(ar,6);
    ...

    void exchange{int ar[], int nar){
    int tmp,i;
    for(i=0;i<(nar+1)/2;i++){
    // exchange values of ar[i] and ar[nar-i-1]
    }
    }

Answer This Question

First Name:
School Subject:
Answer:

Related Questions

More Related Questions

Post a New Question