int p=5,q=12,r=20,s;
s=p+q;
System.out.println(“p+q is”+s);
s=p%q;
System.out.println(“p%q is”+s);
s*=r;
System.out.println(“s*=r is”+s);
System.out.println(“Value of p before operation is”+p);
p++;
System.out.println(“Value of p after operation is”+p);
double x=25.75,y=14.25,z;
z=x-y;
System .out.println(“x-y is” +z);
z-=2.50;
System.out.println(“z-=2.50 is “+z);
System.out.println(“Value of z before operation is”+z);
z--;
System.out.println(“Value of z after operation is”+z);
Z=x/y;
System .out.println(“x/y is” +z);
}
}
Đầu ra của chương trình là
p+q is 17
p%q is 5
s*=r is 100
Value of p before operation is 9.0
Value of z after operation is 8.0
x/y is 1.8070175438596429
3.8.2
Toán tử Bit
Các toán tử dang Bit cho phép ta tạo những Bit riêng biệt trong các kiểu dữ liệu nguyên
thuỷ. Toán tử Bit dựa trên cơ sở đại số Boolean. Nó thực hiện phép tính trên hai đối số là
các bit để tạo ra một kết qủa mới. Một vài dạng toán tử kiểu này được liệt kê dưới đây
Toán tử
Mô tả