Explain the following with an example segment: Modulus Operator
Advertisements
प्रश्न
Explain the following with an example segment:
Modulus Operator
कोड लेखन
स्पष्ट कीजिए
Advertisements
उत्तर
The Modulus Operator (%) in Java is an arithmetic operator used to find the remainder when one number is divided by another number.
It is commonly used to check whether a number is even or odd.
Example Code Segment:
int a = 10, b = 3;
int result = a % b;
System.out.println(result);
Output:
1
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
अध्याय 6: Variables and Expressions - EXERCISE [पृष्ठ १३१]
