J. Daisy - 4 years ago 85

C Question

I just read an book about programming, I found a operator that I do not understand like

`/=`

Here the example :

`for(x = 0, y = 4, z = 4000; z; z /= 10)`

Anyone can explain ?

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

```
z /= 10;
```

is the same as

```
z = z / 10;
```

The condition in your for loop is **not** `z /= 10`

. The condition is `z`

(aka `z != 0`

) so the loop continues until `z`

becomes zero.

Assuming that `z`

is an integer, you'll get this:

```
1st loop: z = 4000
2nd loop: z = 400
3rd loop: z = 40
4th loop: z = 4
```

Then there wont be more loops as `z`

will become zero (as 4/10 is zero for integer division) and the loop will stop.

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**