Exemple d’utilisation de l’operator Modulo ‘%’

Author:


{filelink=4589}

public class Modulo {

  public static void main(String[] args) {
    int i = 100;
    double d = 2;

    System.out.println("i mod 10 = " + i % 6);
    System.out.println("d mod 10 = " + d % 10);
  }
}
/*
i mod 10 = 4
d mod 10 = 2.0
*/

Leave a Reply

Your email address will not be published. Required fields are marked *