Write a Java program to print Pre Decrement operation ?

Write a Java program to print Pre Decrement operation ?

Program
public class Main
{
	public static void main(String args[])
	{
		int x=10;
		System.out.println("The PreDecrement value is "+(--x));
	}
}	

Output:

The PreDecrement value is 9

Using CommandLine Arguments
public class Main
{
	public static void main(String args[])
	{
        int x;
        x=Integer.parseInt(args[0]);
        System.out.println("The PreDecrement value is "+(--x));
	}
}	

Output:

The PreDecrement value is 9

Using Scanner Class
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
        int x;
        Scanner s=new Scanner(System.in);
        System.out.println("Enter x value");
        x=s.nextInt();
        System.out.println("The PreDecrement value is "+(--x));
	}
}	

Output:

Enter x value
10
The PreDecrement value is 9





More Questions


4 . Write a Java program to print Pre Decrement operation?
5 . Write a Java program to print post Decrement operation?
6 . Write a java-program to print addition of two numbers
7 . Write a Java-program to print subtraction of two numbers
8 . Write a Java-program to print multiplication of two numbers
9 . Write a Java-program to print division of two numbers
10 . Write a Java-program to print modular division of two numbers
11 . Write a java-program to print swaping of two numbers with using third variable
12 . Write a Java-program to print swaping of two numbers without using third variable
13 . Write a java-program to print relation of two numbers
14 . Write a Java-program to print logical operators program using &&, || ,!