Monday, 8 June 2015

Arithmetic Operator Demo in Java

public class arithmetic-op
{
  public static void main(String args[])
  {
    i = 5;
    System.out.print("The Value of i: "+ i);
    
    i = i + 5;
    System.out.print("\nThe Value of i: "+ i);
    
    i = i - 2;
    System.out.print("\nThe Value of i: "+ i);
    
    i = i * 2;
    System.out.print("\nThe Value of i: "+ i);
    
    i = i / 4;
    System.out.print("\nThe Value of i: "+ i);
    
    i++;
    System.out.print("\nThe Value of i: "+ i);
    
    i++;
    System.out.print("\nThe Value of i: "+ i);
    
    i --;
    System.out.print("\nThe Value of i: "+ i);
    System.out.println();
  }
}
Output:
The Value of i: 5
The Value of i: 10
The Value of i: 8
The Value of i: 16
The Value of i: 4
The Value of i: 5
The Value of i: 6
The Value of i: 5

No comments:

Post a Comment