float

please help me,,
example:
a = 4.5937;
c = a + 4; ->( a = 4.59)..
thanks
+ (plus) is a binary operator. It takes two operands. The result is the sum of the operands. NEITHER OF THE OPERANDS IS CHANGED BY THIS PROCEDURE..
Thus if you have two numbers 2 and 3 and add them together, you get the answer/result 5 but 2 is still 2 and 3 is still 3.
This is the same for variables: a + 4 gives a result, but a is not changed.
To change a variable you use the assignment operator =

So in your example the result of a +4 which is 8.5937 is put into c , and a
remains 4.5937

If you want to change the value of a, then you say
a = a+4 or the shorthand way a+= 4;
Last edited on
Topic archived. No new replies allowed.