hey there i find it difficult to write pseudocode of two stacks that sum two binary numbers and print the answer i can use a third stack for help. for example S1 is 11001110 and S2 101010 the answer will print 11111000 please help me with that

Recommended Answers

All 4 Replies

What have you tried so far?

Do you have more specific instructions? What is supposed to go into the stacks? I would guess digits.

You'll need to track some extra data, but you shouldn't need a whole third stack.

cant you just convert it to a decimal number (e.g. int), add them up, and then convert back to binary?

cant you just convert it to a decimal number (e.g. int), add them up, and then convert back to binary?

This looks like an assignment intended to illustrate a few concepts about stacks and arithmetic algorithms; such a conversion would defeat its purpose. But if it's not (Sami will have to tell us), there are indeed simpler ways to add numbers.

If the answer is to print, you do not need another stack but rather a variable to hold the carrier...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.