मराठी

Explain the following operator with an example program: Arithmetic Operator

Advertisements

प्रश्न

Explain the following operator with an example program:

Arithmetic Operator
 
कोड लेखन
स्पष्ट करा
Advertisements

उत्तर

An Arithmetic Operator in Java is used to perform mathematical operations such as addition (+), subtraction (-), multiplication (*), division (/) and modulus (%) on numeric values.

Example:

 
class ArithmeticOperator
{
    public static void main(String[] args)
    {
        int a = 10, b = 3;
        System.out.println("Addition: " + (a + b));
        System.out.println("Subtraction: " + (a - b));
        System.out.println("Multiplication: " + (a * b));
        System.out.println("Division: " + (a / b));
        System.out.println("Modulus: " + (a % b));
    }
}

Output:

Addition: 13
Subtraction: 7
Multiplication: 30
Division: 3
Modulus: 1
shaalaa.com
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 6: Variables and Expressions - EXERCISE [पृष्ठ १३२]

APPEARS IN

धीरज मेहरोत्रा Computer Science [English] Class 12
पाठ 6 Variables and Expressions
EXERCISE | Q 31. (a) | पृष्ठ १३२
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×