English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i also encountered this example
a /= i;
b /= i;

2007-03-17 04:18:01 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

num /= 10 means "divide the variable num by 10 and reset its value to the result."

Thus, if num = 200, then num /= 10 would resullt in num = 20.

With a /= i and b /= i, those mean "divide the variable a (or b) by the variable i and reset the value of a (or b) to the result."

Thus, if a = 10, b = 35 and i = 5, a /= i will make a = 2; b /= i will make b = 7.

You can also do += (addition), %= (modulus), *= (multiplication) and -= (subtraction).

2007-03-17 04:53:43 · answer #1 · answered by Anonymous · 1 0

That is num = num / 10;

x /= y means x = x / y;

2007-03-17 11:23:50 · answer #2 · answered by Andy T 7 · 0 0

it means the same thing as

num = num / 10;

You can do the same thing with +, *, or -.

2007-03-17 11:30:17 · answer #3 · answered by Phaedrus 3 · 0 0

a/=i
this is known as short hand assignment
it is equivalent to
a=a/i
the same can be done for
a+=i
a-=i
a*=i
as far as i know this is mainly used in cases where the variable name is long .This coding avoids typing the variable name both sides

2007-03-18 10:50:37 · answer #4 · answered by pavi 3 · 0 0

fedest.com, questions and answers