Friday, October 26, 2007

Provide yourself an example (not one from your instructor) of how you use a particular command that
will help jog your memory in the future when you need that command again. You must provide a little
code as well as a written explanation with this one.

In order to switch two values, there needs to be an additional new variable that is assigned the value of one of the things to be switched up. The following, for example, will not process the right way:

//to switch the two up:
int a = int b;
int b = int a;
// this would give them bot the value of b

To do the right switching up, this has to be done:

int x = int a;
int a = int b;
int b = int x;
// this would work correctly.
It is important to know how this works as such things might be used in many applications. One can use it, for instance, for alphabetizing.
[Ms. Petr, I did this at home because I forgot to do it in class.]

No comments: