PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, August 13, 2022

[FIXED] How does reminder operator works in Java (%) when the dividend is less than the divisor?

 August 13, 2022     operators, output     No comments   

Issue

I would like to know the specific reason why the following code returns the following output.

int myReminder = 3%10; //note that the dividend (3) does not fit in the divisor(10); System.out.println(myReminder);

output: 3

Why does it returns me 3? I would like an specific reason, thank you!...


Solution

Okay, so sometimes when dividing there is something left over. It is called the remainder.

  • Case 1: 21%10. In this case, you can divide 21 into groups of 10 a maximum of 2 times. So there is a 1 left. So, that is the remainder.

  • Case 2: 3%10. In this case, you can divide 3 into groups of 10 a maximum of 0 times, i.e., you cannot divide it. So, at the end you have 3 left as the remainder.



Answered By - Muhammed Jaseem
Answer Checked By - Marie Seifert (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing