Page 1 of 1

Random number calculator help

Posted: 24 Oct 2010 12:36
by kevies99
hi everyone,

i've been working on a random number calculator
this is what i have already:

set random1=
set /p random1=%random%
set random2=
set /p random2=%random%
set /p sum=%random2%-%random1%
set /a ans=%sum%
echo = %ans%

it goes wrong when i want it to auto calculate, at: set /p sum=%random2%-%random1%
it gives the calculation, but when i want the answer, it says Missing operhand.
i want it to calculate random 2 minus random 1 automaticly. (that i don't have to fill in any numbers).

Thanks :wink:

Re: Random number calculator help

Posted: 24 Oct 2010 14:25
by amel27

Code: Select all

set random1=%random%
set random2=%random%
set sum=%random2%-%random1%
set /a ans=%sum%
echo %sum%=%ans%

Re: Random number calculator help

Posted: 25 Oct 2010 01:20
by kevies99
thanks, it works perfectly