Advertisement

tiny % questjun

Started by July 20, 2001 03:09 PM
5 comments, last by Jesper T 23 years, 7 months ago
could any1 verify that this is correct plz (its in c++ ) 4 % 3 = 3 4 % 5 = 1 6 % 8 = 2 thanks
4 mod 3 = 1

4 mod 5 = 4

6 mod 8 = 8

mod is modular division - remember grade school math well mod is just the remainder so

4 mod 3 is 1 remainder 1 so the answer is 1
4 mod 5 is 0 remainder 4 so the answer is 4
.
.
.

hope that helped


Smile, it won''t let you live longer, but it is funny when they die with a smile.
Smile, it won't let you live longer, but it is funny when they die with a smile.
Advertisement
The last one should be 6 mod 8 = 6 tho
And yes, you are correct, if you swap your operands...

3 % 4 = 3

5 % 4 = 1

8 % 6 = 2

G''luck,
-Alamar
ok thanks

btw:
if you have a &ref to array[0], and you want &ref to point at array[1] .. would this be the correct way to change it:

&( ref += 1 )

or... ?
im not getting any errors when i do it like that, but i get some weird results..
You cannot do pointer arithmetic on a reference. There might be a tricky way to do it but the whole point of references forbids it

You should use a pointer instead.

Seeya
Krippy
Advertisement
ok thanks again

This topic is closed to new replies.

Advertisement