Hey, it's been quite awhile since I last posted, but I'm stuck. What I'm supposed to do is look at this code and tell what would appear on the output screen. I ran the program and found that it should display: 2 3 6 1 5 0. However, I just don't see how those numbers are obtained. Here's the code:
#include<iostream>
using namespace std;
int main()
{
int a[ 6 ]={ 2, 6, 3, 7, 1, 5 }, t = 0;
for( int i = 0; i < 6; i++ )
{
if ( a [ i + 1 ] < a[ i ] )
{
t = a[ i ];
a[ i ] = a[ i + 1 ];
a[ i + 1 ] = t;
}
}
for( int k = 0; k < 6; k++ )
cout << a[ k ] << " ";
return 0;
}
Thanks ahead of time for the help.