Write a Java program to print Pre Increment operation ?

Write a Java program to print Pre Increment operation?

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

Output:

The PreIncrement value is 11

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

Output:

The PreIncrement value is 11

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 PreIncrement value is "+(++x));
	}
}	

Output:

Enter x value
10
The PreIncrement value is 11





More Questions


2 . Write a Java program to print Pre Increment operation?
3 . Write a Java program to print post Increment operation?
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