B
Bo
Hi, thanks for everyone's help and flames. I think I solved the prob
but was surprised that no one noticed.
Problem:
Given this expression, a, b never increase under my compiler.
double answer=0.0;
for( int i=0, double a=0.0, double b=0.0 ; i<100 ; i++, a+=0.1, b+=0.1
)
answer += i+a+b;
Reason:
because of the required comma separator in the for loop, it is
syntactiacally incorrect to declare both int and double in the for
loop. (though my compiler compiled anyway...)
This works:
double answer=0.0;
int i=0;
for(double a=0.0, b=0.0 ; ... ; ...)
....
The moral? Be careful of abbreviative shortcuts.
but was surprised that no one noticed.
Problem:
Given this expression, a, b never increase under my compiler.
double answer=0.0;
for( int i=0, double a=0.0, double b=0.0 ; i<100 ; i++, a+=0.1, b+=0.1
)
answer += i+a+b;
Reason:
because of the required comma separator in the for loop, it is
syntactiacally incorrect to declare both int and double in the for
loop. (though my compiler compiled anyway...)
This works:
double answer=0.0;
int i=0;
for(double a=0.0, b=0.0 ; ... ; ...)
....
The moral? Be careful of abbreviative shortcuts.