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 [पृष्ठ १३१]
