Need quick help with C programming language!
Write in C language term: t= (5x-2y)/7z
Pls guys I need urgent help on this
I'm a bit rusty on C but this should work :
float t; t = (float) ( (5.0f*x - 2.0f*y) / 7.0f*z)
and make sure that x,y,z are also floats, else do a cast. Also z should never be zero!
there's an error: if the divider is 7z (7 multiplied by z), then should be:
t = (float) ( (5.0f*x - 2.0f*y) / (7.0f*z)); - feel the difference
this is because multiplication operators in C (* / %) are executed left-to-right (they have equal rank), so we must enclose last operand (7z) in brackets to force multiplication be calculated before division.
cheers
edit: also, you don't need that float cast - it's done automatically since your var is float. and all the subexpressions are at least float in this case.
Yes, the braces are necessary indeed, good finding! The casts aren't explicitly necessary, yes, they are just good practice so you could leave them out!
t = (float) ( (5.0f*x - 2.0f*y) / (7.0f*z));
true, did it fast
KURWA WHY NO JAVA OR PHP OR AS3 ?
Ty, u saved my best friend