Answers for "use & to check even and odd in c"

C
0

use & to check even and odd in c

/* Program to check if number is even or odd
 * using bitwise operator
 */
#include<stdio.h>
 
int main()
{
   int n;
 
   printf("Enter an integer: ");
   scanf("%d",&n);
 
   if ( n & 1)
      printf("%d is an odd number", n);
   else
      printf("%d is an even number", n);
 
   return 0;
}
Posted by: Guest on August-17-2021

Code answers related to "C"

Browse Popular Code Answers by Language