Need quick help with C programming language!

8 replies [Last post]
*ZMB*SEEBZ*
Seebz's picture
Offline
Joined: Oct 2007
Posts:

Write in C language term: t= (5x-2y)/7z

Pls guys I need urgent help on this Happy

¯¯__█ALI█¯¯__
xpaliminium's picture
Offline
Joined: Nov 2005
Posts:
Re: Need quick help with C programming language!

I'm a bit rusty on C but this should work :

float t;
t = (float) ( (5.0f*x - 2.0f*y) / 7.0f*z) 

Wanna avoid seeying mow, skull & co Surprise

Check this peacefull place

*ZMB*SEEBZ*
Seebz's picture
Offline
Joined: Oct 2007
Posts:
Re: Need quick help with C programming language!

Ty, u saved my best friend Happy

BOZO
Bozo's picture
Offline
Joined: Feb 2010
Posts:
Re: Need quick help with C programming language!

and make sure that x,y,z are also floats, else do a cast. Also z should never be zero! Winking

^t
smasherchif's picture
Offline
Joined: Oct 2009
Posts:
Re: Need quick help with C programming language!

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.


.aNk/xXxp4l/:bR.Shady'XYN! wrote:
Fuck! I just thought of the most awesome pun about the BC vs Smurfs final game and the flames that followed :
"In Soviet Moldavia, Pole rages YOU"
like 2 months after Call me

3M'darkangel wrote:
// 09:30:49 27.06.2010, UNKNOWN LOCATION,
Name { "Biotoxin" }
IP { "localhost" }

SHUDDER wrote:
People are training hard to hide their autoshoot so well while gain enough skills to win (or at least compete on similar level) without them. This is getting insane or provoked. I feel like I would cut myself with Ockham's Razor if I claim a cheat there.

BOZO
Bozo's picture
Offline
Joined: Feb 2010
Posts:
Re: Need quick help with C programming language!

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! Tongue

¯¯__█ALI█¯¯__
xpaliminium's picture
Offline
Joined: Nov 2005
Posts:
Re: Need quick help with C programming language!
^t wrote:

t = (float) ( (5.0f*x - 2.0f*y) / (7.0f*z));

true, did it fast Confused

Wanna avoid seeying mow, skull & co Surprise

Check this peacefull place

..ZMB..EPYKOI
epykoi's picture
Offline
Joined: Jun 2007
Posts:
Re: Need quick help with C programming language!

KURWA WHY NO JAVA OR PHP OR AS3 ? Chatterbox



*ZMB*SEEBZ*
Seebz's picture
Offline
Joined: Oct 2007
Posts:
Re: Need quick help with C programming language!

Thank you all!!!

And epy, next time Winking