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; ...

C Program to Add Two Numbers Without '+' Operator

Binary Addition Without '+' in C

✅ C Program to Add Two Numbers Without '+' Operator

#include <stdio.h>

int main() {
    int a, b;
    printf("Enter two numbers:\n");
    scanf("%d %d", &a, &b);

    while (b != 0) {
        int carry = a & b;     // Calculate carry
        a = a ^ b;             // Add without carrying
        b = carry << 1;        // Shift carry to the left
    }

    printf("Sum is: %d\n", a);
    return 0;
}
  

πŸ“˜ Explanation:

This program adds two numbers without using the + operator. It uses bitwise operations:

  • a ^ b calculates the sum without carry
  • a & b finds the carry
  • carry << 1 shifts the carry to the next bit
  • The loop continues until there’s no carry

πŸ–₯️ Sample Output:

Enter two numbers:
5 3
Sum is: 8
  

πŸ”‘ Keywords:

add without plus, bitwise sum, binary addition, C program without + operator, xor carry logic, beginner bitwise program

πŸ“Œ Hashtags:

#CProgramming #BitwiseOperations #BinaryAddition #NoPlusOperator #XORLogic #BeginnerC

Comments

Popular Posts

πŸŒ™