Check number is Odd or Even without using Modulus Operator in C
Here you will a new tricky method to check that the input number is Odd or Even without using Modulus Operator in C programming. The quick method to solve this problem, We can use bitwise & operator.
Program to Check Odd or Even without using Modulus Operator in C
1 2 3 4 5 6 7 8 | #include<stdio.h> int main() { int n; printf("Enter a number : "); scanf("%d",&n); (n&1)?printf("Number is Odd"):printf("Number is Even"); } |
Output
Enter a number : 15
Number is Odd
Enter a number : 8
Number is Even
Check out our other C programming Examples