Here is the source code of the C program to perform addition operation using bitwise operators. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
int bitwiseadd(int x, int y)
while (y != 0)
int carry = x & y;
x = x ^ y;
y = carry << 1;
int num1, num2;
printf("\nEnter two numbers to perform addition using bitwise operators: ");
scanf("%d%d", &num1, &num2);
printf("\nSum is %d", bitwiseadd(num1, num2));
$ gcc bitwiseadd.c -o bitwiseadd $ ./bitwiseadd Enter two numbers to perform addition using bitwise operators: 20 12 Sum is 32
Sanfoundry Global Education & Learning Series – 1000 C Programs.