How do i check whether any random number A is odd or even in java, without using if-else or switch-case
Answers
Answered by
2
Answer:
include<stdio. h> main() { int n; char *arr[2] = {"Even", "Odd"}; printf("Enter a number: "); //take the number from the user scanf("%d", &n); (n & 1 && printf("odd"))|| printf("even"); //n & 1 will be 1 when 1 is present at LSb, so it is odd. }
Similar questions
Biology,
18 days ago
Math,
18 days ago
Computer Science,
1 month ago
Math,
9 months ago
Biology,
9 months ago