The Code was made in notepad++ and made intoa .batch file. I want to add more questions but find it difficult. can some help

@echo off
title game 
:menu
echo 1) start
echo 2) intro
echo 3) exit
set /p menu=

if %menu% == 1 goto game
if %menu% == 2 goto help
if %menu% == 3 exit

:help
cls
echo hit the correct answer and press enter.
pause

:game
echo what is your name?
set /p name=
echo hello %name%!
pause
cls
echo who was the first president of the USA?
echo 1) George Washington
echo 2) Pierre Desperau
set /p ab=

if %ab% == 1 goto cr1
if %ab% == 2 goto wr1

:cr1
echo correct
pause
goto menu

:wr1
echo wrong
pause
goto game
cls

Dani AI

Generated

A simple, maintainable approach for is to move every question out of the .bat logic and into a plain text file. That makes "adding more questions" a matter of appending lines to the data file instead of editing labels and gotos. is right to warn about goto-heavy code — a single FOR /F loop that reads each record is easier to extend, debug and reuse.

Create a questions file where fields are separated by a character unlikely to appear in text (example uses #). Each line is one record: question#option1#option2#option3#correctNumber. The batch snippet below shows the minimal reader/asker; new questions are added simply by appending lines to questions.txt.

@echo off
setlocal enabledelayedexpansion
set "qfile=questions.txt"
set /a score=0

for /f "usebackq tokens=1-5 delims=#" %%A in ("%qfile%") do (
  set "q=%%A"
  set "o1=%%B"
  set "o2=%%C"
  set "o3=%%D"
  set "correct=%%E"
  echo.
  echo !q!
  echo 1) !o1!
  echo 2) !o2!
  echo 3) !o3!
  set /p "ans=Answer (1-3): "
  if "!ans!"=="!correct!" (
    echo Correct!
    set /a score+=1
  ) else (
    echo Wrong. Correct was !correct!
  )
)
echo.
echo Final score: %score%
endlocal
pause

Notes and troubleshooting:

  • Use a delimiter that won't appear in questions; pick another char if # is used in content.
  • EnableDelayedExpansion is required so variables updated inside the FOR loop expand correctly.
  • Quote comparisons (if "%var%"=="1") to avoid errors when input is empty.
  • To support more options or variable-length option lists, use tokens=1* and split the remainder in a second pass, or move to PowerShell/Python for easier parsing and shuffling.

This keeps logic small and makes adding or fixing questions a one-line edit to questions.txt rather than changing the script structure.

The reason you are finding it difficult is because this is a dog's breakfast of a piece of code. That is not the way to write a program that runs a multiple choice quiz. In its simplest form you would have a text file where each record (line) contains the same number of fields separated by a unique delimeter cush as

question | option a | option b | option c | correct answer

You would read/display each question in turn from the file until all the questions have been asked and answered.

You would also NOT use gotos.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.