4
Contributors
6
Replies
7
Views
11 Years
Discussion Span
Last Post by iamthwee
0

Well i want to know the method using bitwise operators.
I don't know exaclty how to do it.
But I can tell you a little bit, so that if you know you can help me.

It's like...
SUM = a XOR b
CARRY= a AND b

0

Here is one idea using the post increment operator:

int a, b;

cout << "\nEnter first number: ";
cin >> a;

cout << "\nEnter second number: ";
cin >> b;

for (int i = 0; i < a; i++)

     b++;

cout << "\nThe answer is: " << b;
0

Thanks clinton
but i wanted to know the answer using bitwise operator.
Is there anyone listening...???

Here is one idea using the post increment operator:

int a, b;

cout << "\nEnter first number: ";
cin >> a;

cout << "\nEnter second number: ";
cin >> b;

for (int i = 0; i < a; i++)

     b++;

cout << "\nThe answer is: " << b;
0

You know how the bitwise operators work, right? You know how to add two numbers in binary, or can look that up, right? Flex your creativity muscles, or you'll continue to be unable to solve your own problems.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.