Penggunaan operator modulus (sisa pembagian)


public class Modulus
{
public static void main (String[ ] args)
{
int a, b; // pendefinisian variabel
double c, d;
a = 9 % 2;
b = 6 % 3;
c = 9.7 % 2;
d = 6 % 3.2;

System.out.println (“9 modulus 2 hasilnya adalah = ” + a);
System.out.println (“6 modulus 3 hasilnya adalah = ” + b);
System.out.println (“9.7 modulus 2 hasilnya adalah = ” + c);
System.out.println (“6 modulus 3.2 hasilnya adalah = ” + d);
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s