why should we choose this % symbol? bcoz we are already have / so why?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

why should we choose this % symbol? bcoz we are already have / so why??

6th Jul 2016, 9:56 AM
Praveen Kumar S
Praveen Kumar S - avatar
7 Answers
+ 5
% is an operator which gives remainder when two numbers are divided. Whereas / is a operator used to perform division and it gives the quotient.
6th Jul 2016, 10:37 AM
VARUN MALIK
VARUN MALIK - avatar
0
% is the modulos operator which gives the reminder of a division, and / is the division symbol
6th Jul 2016, 8:03 PM
nathandrake
0
The modulos // % // operator is fairly conventional across most languages, best make friends with it
6th Jul 2016, 9:33 PM
Teagan Johner
Teagan Johner - avatar
0
thanks all
7th Jul 2016, 7:15 AM
Praveen Kumar S
Praveen Kumar S - avatar
0
thanks
7th Jul 2016, 7:15 AM
Praveen Kumar S
Praveen Kumar S - avatar
0
there are many uses for it, a simple common one is to check if a number is even or odd. int main() { int num; cout << "Type in a number\n"; cin >> num; if ((num % 2) == 0) { cout << "The number is even\n"; } else { cout << "The number is odd\n"; } }
11th Jul 2016, 1:29 PM
Dylan Beech
Dylan Beech - avatar
0
the modulus operator, %, outputs the remainder of two divided numbers, while the division operator,/, outputs the amount of times the smaller number(operand) is found in the bigger one. Yeah, that's easier
12th Jul 2016, 4:18 PM
Petersburg IK
Petersburg IK - avatar