- 1
Hi!! I've got a question related to divisions:
int a=5; int b=3; System.out.println(a/b) output??? and also what would be the output of a%b??
2 Réponses
+ 8
As both "a" and "b" are both integers the division between the two of them is also going to be an integer so the first output would be 1 (if you change "a" or "b" to a double, float etc. the answer would be 1.6666666666....)
As for the second part, % (modulus) means the remainder when you perform division so 3 goes into 5 once and the amount remaining is 2 so the answer would be 2 (if you want another example "26 % 7" would be 5 as 7 by 3 is 21 and then the remainder would be 5).
Edit: No problem :)
0
Understood! Thank you so much for ur time!!