Find the remainder without using% operator | In Java - Math Traders

Latest

Find the remainder without using% operator | In Java

            Remainder without using% operator 

 

class Constructor{

public static void main(String[] args) {

//Declaration Of Variables

int num = 19,div = 2;


while(num>=div){

num -=div;

}

System.out.println("remainder is :"+num);


}

}


Output:

remainder is :1

No comments:

Post a Comment