What is the difference between ‘/’ ‘%’ in java
Answers
Answered by
1
Answer:
/ will give u remainder
% will give u quotient
Answered by
1
Hey there!
Difference between "/" and "%" in Java:
• '/' symbol is of division and '%' symbol is called modulus.
• '/' gives the quotient while '%' gives remainder.
For Example:
class Abc
{
public static void main(String args[])
{ int a,b,q,r = 0;
a = 17;
b = 5;
q = 17/5;
r = 17%5;
System.out.println("Quotient="+q);
System.out.println("Remainder="+r);
}
}
Sample Output:
Quotient = 3
Remainder = 2
Good day!
Similar questions
Accountancy,
5 months ago
Hindi,
5 months ago
History,
5 months ago
Math,
11 months ago
Social Sciences,
11 months ago
Chemistry,
1 year ago
English,
1 year ago