What are the array contents X after the execution of the following program segment:
int x [ ] = {10, 2, 3, 4, 1 }, i ;
x[ 4 ] = 2 * x[ 3 ] ;
i = 3 ;
while ( i >= 2 )
{
if ( x[ i ] % 2 == 0 )
x[ i ] = x[ i - 1 ] + 2 ;
else
x[ i ] = 11 ;
i -- ;
}
using namespace std; main(void) { int x[] = {10, 2, 3, 4, 1 }, i ; x[4] = 2*x[3] ; i = 3 ; while ( i >= 2 ) { if (x[i]%2 == 0) x[i] = x[i-1] + 2 ; else x[i] = 11 ; i -- ; } cout<<"\n\tArray Contents: "; for(i=0;i<sizeof(x)/sizeof(x[0]);i++) cout<<x[i]<<", "; return(0); }
Need a fast expert's response?
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Comments