Search This Blog
Welcome to 1printf(), your ultimate destination for C, C++, Linux, Data Structures, and Microcontroller programming! ๐ ๐นLearn advanced coding techniques in C& C++ ๐นMaster Linux internals & shell scripting ๐นDeep dive into Data Structures & Algorithms ๐นExplore Embedded Systems & Microcontrollers (8051,UART, RTOS) ๐นGet hands-on coding tutorials, project ideas,and interview preparation tips Whether you're a beginner or an experienced programmer, this channel will help you
Featured
- Get link
- X
- Other Apps
Check Even or Odd using Bitwise AND in C
✅ Check Even or Odd Using Bitwise AND in C
#include <stdio.h>
int main() {
int num;
printf("Enter a number:\n");
scanf("%d", &num);
// Using bitwise AND operator
if (num & 1)
printf("%d is Odd\n", num);
else
printf("%d is Even\n", num);
return 0;
}
๐ Explanation:
This C program determines whether a number is even or odd using the bitwise AND operator:
- In binary, even numbers end with 0 and odd numbers end with 1.
num & 1isolates the last bit of the number.- If the result is 1, the number is odd. If it's 0, it's even.
๐งพ Sample Output:
Enter a number: 11 11 is Odd Enter a number: 24 24 is Even
๐ Keywords:
Bitwise AND, Even or Odd using bitwise, C program for parity check, binary logic, bitwise operators, embedded C tricks
๐ Hashtags:
#CProgramming #BitwiseOperations #EvenOddCheck #BinaryLogic #BeginnerC #EmbeddedC #CodingTricks
Popular Posts
C++ Program for Hybrid Inheritance (All Types Together)
- Get link
- X
- Other Apps
C++ Program for Function Overloading Example
- Get link
- X
- Other Apps
Comments
Post a Comment