# Pseudocode Help

Discussion in 'Mac Programming' started by gameguy3001, Sep 26, 2007.

1. ### gameguy3001 macrumors member

Joined:
Feb 8, 2007
Location:
#1
For a Computer Science class I'm taking. We are giving a algebraic equation and asked to write it in Pseudocode. I know I have to create variables for it but I'm not sure what the equation should look like.

If someone could post a example of what a equation could be and its equivalent in Pseudocode that would help a lot.

Thanks

2. ### angelwatt Moderator emeritus

Joined:
Aug 16, 2005
Location:
USA
#2
Code-wise: int var1 = 40; int var2 = 30; int newValue = var1 + var2;

Pseudo-wise: a + b = c

Of course the equations are usually more complex, but this is a basic look. There really isn't anything to it.

3. ### gameguy3001 thread starter macrumors member

Joined:
Feb 8, 2007
Location:
#3
Thanks

I guess I was thinking it would be more complicated

4. ### kpua macrumors 6502

Joined:
Jul 25, 2006
#4
Don't you think that should be c = a + b? Pseudo-code is definitely not math. You still need to show assignment similar to how we do it in code. a + b = c looks like you're trying to assign a+b the value of c, which is nonsense.

In pseudo-code, the symbols you use really aren't terribly important, as long as you get the correct idea across. The above works, but I often see arrows used to make the assignment more explicit, as in the following:

c <- a+b

It's really all your preference, unless you get a teacher who's really strict about it. (You'd be surprised...)

5. ### MongoTheGeek macrumors 68040

Joined:
Sep 13, 2003
Location:
Its not so much where you are as when you are.
#5
I kinda like the idea of right handed assignment statements. I have vague memories of some language that does it. a + b -> c

I can even see uses for a programming language that would accept assigning a value to an equation. Constrain a and b such that their sum is c. Each would then be an array of possible values.

6. ### angelwatt Moderator emeritus

Joined:
Aug 16, 2005
Location:
USA
#6
Well he specifically mentioned pseudo code for an equation so that's why I did it like that. As far as I've ever seen there's no rules for pseudo code, but I understand your point. Usually when I do pseudo code (which is rare) I use sentence form, kind of like AppleScript.

7. ### cruzrojas macrumors member

Joined:
Mar 26, 2007
Location:
USA
#7
On a Texas Instrument calculator you set values to your variables in this way. The language used by this calculators is similar to BASIC.

8. ### bousozoku Moderator emeritus

Joined:
Jun 25, 2002
Location:
Gone but not forgotten.
#8
COBOL works math to the right, except for the COMPUTE statement:

Code:
```ADD A TO B GIVING C.
```
It's also good for a pseudocode experience.

I wouldn't suggest using 1 character variable names, though, unless you're using a calculator.