Batch File Heads or Tails Generator

589

3

2

Posted

Introduction: Batch File Heads or Tails Generator

Code for a random heads or tails generator.

  1. Open notepad
  2. Copy code below
  3. Save it as ht.bat and click TEXT DOCUMENT and change it to ALL FILES
  4. Click save

@echo off

:top

cls

echo To flip the coin press enter

set /p enter=

set /a a=%random% %% 2+1

if %a% EQU 1 (

echo Heads pause goto top

)else echo Tails pause goto top

Share

Recommendations

  • Epilog Challenge 9

    Epilog Challenge 9
  • Sew Warm Contest 2018

    Sew Warm Contest 2018
  • Gluten Free Challenge

    Gluten Free Challenge
user

We have a be nice policy.
Please be positive and constructive.

Tips

Questions

2 Comments

I have made a new version of this for every one. Copy and paste this code:

@echo off

cls

:loop

cls

set /a a = 0

set /a b = 0

:game

cls

set /p ht= Press enter to flip the coin.

echo KACHING!!!

pause

set /a th = %random% %% 2+1

if %th% == 1 (

goto c

)else if %th% ==2 (

goto d

)else goto game

:c

cls

echo HEADS

echo.

echo -------------------

echo.

set /a a = %a% + 1

echo Heads: %a%

echo Tails: %b%

pause

goto game

:d

cls

echo TAILS

echo.

echo --------------------

echo.

set /a b = %b% + 1

echo Heads: %a%

echo Tails: %b%

pause

goto game