Skip to main content

Featured

Mastering Hollow Square Patterns in C: Stars, Numbers, Alphabets & Binary

πŸ”’ C Program to Print Hollow Continuous Number Square πŸ“„ Source Code: #include <stdio.h> int main() { int num, k = 0; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { if(i == 1 || i == num || j == 1 || j == num) { // k increments sequentially only along the borders printf("%d ", k++); } else { printf(" "); } } printf("\n"); } return 0; } πŸ“‹ Copy Code πŸ’» Expected Output (Input: 5): Enter the number: 5 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 πŸ”’ C Program to Print Standard Hollow Binary Row Square πŸ“„ Source Code (Fixed Specifier): #include <stdio.h> int main() { ...

Check Even or Odd using Bitwise AND in C

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 & 1 isolates the last bit of the number.
  • If the result is 1, the number is odd. If it's 0, it's even.
This method is efficient and used in low-level systems and embedded code for performance.

🧾 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

Comments

Popular Posts

πŸŒ™