//Qus #3:- Check User Enter Number is Even Or Not Without Modulus Operator?
Solution:-
import java.util.Scanner;
public class Even_Or_Odd {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
System.out.println("Enter the number");
int n =sc.nextInt();
if(n/2*2==n)
{
System.out.println(n+" User Enter Number Is Even");
}
else
{
System.out.println(n+" User Enter Number Is Odd");
}
}
}
🤖Explanation: let's suppose User Entered Number is (n=62)
let's Check The Condition (n/2*2==n)
👉62/2*2=62
👉124/2=62
👉62=62
🤙That's why User Enter Number is Even
🤦♂️Try Your Self Buddy, If you Get any Error just Comment Below, Definitely, I will try to Solve Your Problem.
0 Comments