Java program to left shift a number

Java program to multiple a number by 2.
Java example Program for left shift a number

Program:-

import java.util.Scanner;
class group{
public static void main(String arg[]){
int num;
Scanner data = new Scanner(System.in);
System.out.println("Enter a number");
num = data.nextInt();
num=num<<2;
System.out.println("Answer:"+num);
}
}

Output:-

Enter a number
5
Answer:20

Output:-

Enter a number
25
Answer:100
 


Learn Java:-
Java codes

Java Programs:-
List of Java Programs

Leave reply

Add your comments here

Back to Top