English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Write pseudocode to solve the "swap" problem: get the user to enter integer values into variables a and b, and then store the user's value for b in variable a and the user's value for a in variable b. For example, if the user entered 7 and 8, so that we had a=7 and b=8 initially, we want to finish with a=8 and b=7.

2007-11-01 11:13:33 · 4 answers · asked by sdc 1 in Computers & Internet Programming & Design

4 answers

If you have a stack it is easy.

Get integer into register A
Get integer into register B
Push down register A onto stack
Pick up register B contents
Store it in register A
Pop off stack into Register B.

2007-11-01 11:19:16 · answer #1 · answered by Rich Z 7 · 0 0

i'm conflicted with regards to the political panorama. I scares me to no end that this super united states is slowly yet fairly, reducing God out of it. Piece by using piece. and then we ask your self why a lot of issues? you won't be able to be a rustic of entitled toddler murderers and assume advantages from God in simple terms as you won't be able to be a three p.c.. an afternoon smoker and assume therapeutic of Emphysema. I genuinely believe and believe in the Lord. The Lord places adult males in positions of means for a reason/purpose. i do no longer could know it. I in simple terms could settle for it and believe in Him that his will would be fulfilled. With Christ as my Lord and Savior, i'm going to be taken care of inspite of the international collapsing around me. i'm bobbing up my "faint" muscle by way of fact the greater I understand, the greater it hurts.

2016-10-03 03:14:35 · answer #2 · answered by Anonymous · 0 0

int a,b,c;

get A
Get B

C=a;
a=b;
b=c;

2007-11-01 11:18:13 · answer #3 · answered by ? 6 · 0 0

int a,b ;

a = a + b;
b = a - b;
a = a - b;

2007-11-01 11:27:07 · answer #4 · answered by Liquid Metal!! 2 · 0 0

fedest.com, questions and answers