CODE:
import java.util.*;
class Shift
{
public static void main(String args[])
{
int a;
float b1,b2;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number:");
a=sc.nextInt();
b1=a<<3;
System.out.println("After shifting three bits left:="+b1);
b2=a>>3;
System.out.println("After shifting three bits right:="+b2);
}
}
OUTPUT:
import java.util.*;
class Shift
{
public static void main(String args[])
{
int a;
float b1,b2;
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number:");
a=sc.nextInt();
b1=a<<3;
System.out.println("After shifting three bits left:="+b1);
b2=a>>3;
System.out.println("After shifting three bits right:="+b2);
}
}
No comments :
Post a Comment