Skip to main content

Featured

C Pattern Programs: Square Number and Alphabet Patterns Explained

πŸ”· Square Star Pattern πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = 1; i <= num; i++) { for(int j = 1; j <= num; j++) { printf("* ");//keep"* " } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Column-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; printf("Enter the number:\n"); scanf("%d", &num); for(int i = num; i >= 1; i--) { for(int j = num; j >= 1; j--) { printf("%c ", j + 64);//%c for Character and 64 will be ASIIC VALUE } printf("\n"); } return 0; } πŸ”· Reverse Square Alphabet Pattern (Row-wise) πŸ“‹ Copy Code #include <stdio.h> int main() { int num; ...

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

πŸŒ™