An algorithm is just another name for a program. What programming language are you using?
A basic way of doing this in, erm, BASIC, goes something like this:
let a=1
let b=2
let total=a+b
print total
end
The first line puts the number 1 into a variable named "a." Likewise, the second line puts the number 2 into "b." the third adds them together and puts the total (which is 3, obviously) into the cryptically named "total" variable. Line 4 then displays whatever is stored in "total" (3) on screen, and the last ends the program.
__________________ "Computer games don't affect kids - I mean, if Pacman affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music."
- Kristian Wilson [Nintendo Executive 1989] Anyone fancy going out clubbing tonight? |