0

What does the % in this code mean?

From x[4] = {0,1,2,3} x[i] = i%2 x[1] = 1%2 = 1 How is that possible? I thought % means remainder. How is x[1] = 1?? Correct me if i'm wrong please.

2nd Feb 2019, 2:22 PM
.Houdini
.Houdini - avatar
2 Respostas
+ 5
% does means remainder. If you take a smaller number and divide it by a larger one, say x/y, you'll always get x as the answer for x%y This is because let's say for 27%100, 100 will go 0 times for 27 that is: 27=(100*0)+27
2nd Feb 2019, 2:49 PM
Kawalpreet Juneja
Kawalpreet Juneja - avatar
+ 4
1 divided by 2, is 0 with remainder of 1.
3rd Feb 2019, 6:11 AM
Hatsy Rei
Hatsy Rei - avatar