+ 1

What does % do?

I don’t know for what this is used for, is it for some sort of division? I found it in a solution for the popsicles code challenge, and am now wondering what it’s doing. https://code.sololearn.com/cfclSYI2rJJJ/?ref=app

29th Aug 2023, 10:02 AM
Paul Schmidt
5 Respuestas
+ 10
Paul Schmidt % returns the remainder of a division. Example: 20%3 = 2 Let's break it down. How many times does 3 go into 20? -> 6 6 × 3 = 18 Which gives a REMAINDER of 2 20 - 18 = 2
29th Aug 2023, 10:07 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 3
remainder = in German „Rest“, also das was übrig bleibt
29th Aug 2023, 10:18 AM
Angela
Angela - avatar
+ 3
Ah Thanks very much for 1) the very detailed explantaion, and 2) die großartige Übersetzung :)
29th Aug 2023, 10:24 AM
Paul Schmidt
+ 1
% <- module operator used for finding reminder from diving to values eg. int x=5,y=11; cout<<y%x; output - 1
31st Aug 2023, 8:49 AM
Alhaaz
Alhaaz - avatar
0
It shows the remainder of the division Like: X=12%5 Print(x) ---------------------- Answer: 2
29th Aug 2023, 8:51 PM
ALIREZA PRO
ALIREZA PRO - avatar