i need help
is dis correct?
sum= (score1/num2) + (score2/num1);
Well that's a pretty incomplete question. Assuming all those variables are correctly declared, that line will compile with no errors. But it's hard to tell you if that's correct because I have no idea what you're trying to do or what kind of data is stored in those variables.
trying to write a formula
Just be careful with your variable types when you're doing division. It you use type int or type char, you won't get the correct result with fractions.
For example: MyFloat = Int1/Int2; will confuse you, because the Int1/Int2 is done first, and the result is stored (in a temporary register) as an int. Everything to the right of the decimal point is "lost" before the value is assigned to MyFloat.
The same thing can happen with integer constants.
(1/2) + (1/2) + (1/2) will give you zero!
(1.0/2.0) + (1.0/2.0) + (1.0/2.0) will give you 1.5
Last edited by DougDbug; 03-03-2006 at 06:08 PM.