First page Back Continue Last page Graphics
Given the following
What would print?
- #include <iostream>
- using namespace std;
- void swap(int *, int *);
- int main ( void )
- { int ary[]={0, 2, 4, 6, 1, 3, 5, 7};
- int last(0);
- for ( int i = 0; i < 8; i++ )
- { last = 7 – i;
- swap( &(ary[i]), &(ary[last]));
- }
- for( int i = 0; i < 8; i++)
- cout << ary[i] << “ “;
- cout << endl; } // end of main
- void swap(int * a_ptr, int * b_ptr)
- { int tmp;
- tmp=*a_ptr; *a_ptr= *b_ptr; *b_ptr=tmp;}