Saturday, 18 November 2017

C++ Program to Perform Addition Operation Using Bitwise Operators


Code:

#include  iostream
#include  conio.h
#include  stdlib.h

using namespace std;
int add(int x, int y)
{
    int carry;
    while (y != 0)
    {
        carry = x & y;
        x = x ^ y;
        y = carry << 1;
    }
    return x;
}
int main(int argc, char **argv)
{

    cout << "Enter the numbers to be added:";
    int x, y;
    cin >> x >> y;
    cout << "The Summation is: " << add(x, y);
}


Output:

Enter the numbers to be added:23 24
The Summation is: 47


More C++ Programs:













100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...