+ 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
5 Respostas
+ 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
+ 3
remainder = in German „Rest“, also das was übrig bleibt
+ 3
Ah Thanks very much for 1) the very detailed explantaion, and 2) die großartige Übersetzung :)
+ 1
% <- module operator
used for finding reminder from diving to values
eg. int x=5,y=11;
cout<<y%x;
output - 1
0
It shows the remainder of the division
Like:
X=12%5
Print(x)
----------------------
Answer: 2