I don't understand the % mark and the array thing. Please, someone explain to me. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I don't understand the % mark and the array thing. Please, someone explain to me.

its because in challenges, i always get defeated in the array amd % section!

12th Feb 2017, 1:23 PM
Sinethemba Gomba
Sinethemba Gomba - avatar
4 Answers
+ 7
% is the modulus operator. It returns the remainder of an expression after division. E.g. 5%2 // outputs 1 4%2 // outputs 0 2%4 // outputs 2
12th Feb 2017, 1:36 PM
Hatsy Rei
Hatsy Rei - avatar
+ 4
i think i understood it the % devides a certain number eg 5%3 and 3 goes once into 5, and the remaining number is 2. that's the %'s use! but u guys xan also give me more info
12th Feb 2017, 1:26 PM
Sinethemba Gomba
Sinethemba Gomba - avatar
0
You have 10 apples and you have to divide them among 3 kids. After giving three apples to each kid, you have one left over. This left over is modulus. And it's mathematical expression is 10%3 = 1. If you have nothing left over, the answer will be 0. Now tell me, 100%7=what?
12th Feb 2017, 3:03 PM
Shakil
Shakil - avatar
0
% is called the modulo operator it gives you the remainder
12th Feb 2017, 4:26 PM
Abdur-Rahmaan Janhangeer
Abdur-Rahmaan Janhangeer - avatar