- #1
asz304
- 108
- 0
Homework Statement
say a[5] = { 5.6, -3.2, 11, -7.7, -1 );
and b = 5
Code:
void fum ( double a[], int b ){
for ( int i = b -1; i >= 0; i-- ){
if ( a[i] < 0 )
cout << -a[i];
else cout << a[i];
cout << ", ";
}
}
Why is the output
1, 7.7, 11, 3.2, 5.6
and not
7.7, 11, 3.2, 5.6 ?
Shouldn't the value of the first i in the for loop 3? and not 4? because i = 5-1 = 4 then it decrements to 3?