Batch File Heads or Tails Generator

Published

Introduction: Batch File Heads or Tails Generator

About: I like to computer program. I like soccer.

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

    • Oil Contest

      Oil Contest
    • Woodworking Contest

      Woodworking Contest
    • Clocks Contest

      Clocks Contest
    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