# How to write an algorithm?



## jnwk888hwq (Jul 27, 2003)

Do anyone here know how to write an algorithm? Please show me some basic? I'm quite new to it as I'm learning computing.

How to write an algorithm that finds the smaller of two numbers a and b? Can anyone enlighten me?

Thanks

Regards


----------



## Corrosive (Jan 9, 2003)

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.


----------



## dtech10 (Jan 31, 2003)

let a=10
let b=15
let lowest=0

if a<b
lowest=a
else
lowest=b
endif
print "lowest=",lowest


----------

