Write a programme that demonstrate modulus operator

Category : Java | Sub Category : Operator | By Runner Dev Last updated: 2020-09-28 15:25:31 Viewed : 211


(Operator)

Write a programme that demonstrate modulus operator

Descriptionin this program, first make a class and write its main method then initialize and declare c and y and print them.


Source Code: Modules.java

/**

 * Write a programme that demonstrate modulus operator

 *

 */

public class Modulas { // class name

     public static void main(String arg[]) { // main method

         int x = 67; // initialize and declare x

         double y = 67.25; // initialize and declare y

         System.out.println("x mod 10 = " + x % 10); // print modulus of x

         System.out.println("y mod 10 = " + y % 10); // print modulus of y

     } // end main method

 

}// end class


Output:




Search
Related Articles

Leave a Comment: