Random number calculator help

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
kevies99
Posts: 2
Joined: 24 Oct 2010 12:27

Random number calculator help

#1 Post by kevies99 » 24 Oct 2010 12:36

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:

amel27
Expert
Posts: 177
Joined: 04 Jun 2010 20:05
Location: Russia

Re: Random number calculator help

#2 Post by amel27 » 24 Oct 2010 14:25

Code: Select all

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

kevies99
Posts: 2
Joined: 24 Oct 2010 12:27

Re: Random number calculator help

#3 Post by kevies99 » 25 Oct 2010 01:20

thanks, it works perfectly

Post Reply