Java Program To Demonstrate Arithmetic Operators
Write Java program to demonstrate the use of arithmetic operators
// WAP to demonstrate arithmetic operators.
public class ArithmeticOperator
{
public static void main(String[] args)
{
int a = 12,b = 8,c;
System.out.println("Value of num1 is : "+a);
System.out.println("Value of num2 is : "+b);
c = a+b;
System.out.println(""+a+" + "+b+" = "+c);
c = a-b;
System.out.println(""+a+" - "+b+" = "+c);
c = a*b;
System.out.println(""+a+" * "+b+" = "+c);
float c1 = a/(float)b;
System.out.println(""+a+" / "+b+" = "+c1);
c = a%b;
System.out.println(""+a+" mod "+b+" = "+c);
c = a+1;
System.out.println(""+a+" + "+1+" = "+c);
c = a-1;
System.out.println(""+a+" - "+1+" = "+c);
}
}
Output: