Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

How to prevent the users answer the same question again!

anymananyman Member Posts: 19
my program is a game ,contain many questions.
How can i prevent user answer the same question again
and write "You did it before!"
I know it have to use boolean
but I have no idea how to do
plz give me an example

Comments

  • zibadianzibadian Member Posts: 6,349
    : my program is a game ,contain many questions.
    : How can i prevent user answer the same question again
    : and write "You did it before!"
    : I know it have to use boolean
    : but I have no idea how to do
    : plz give me an example
    :
    Here is a simple sample code:
    [code]
    var
    AnsweredAlready: array[1..4] of boolean;
    QIndex: integer;
    begin
    repeat
    write('Question number (0=Exit): '); readln(QIndex);
    if QIndex > 0 then
    begin
    if AnsweredAlready[QIndex] then
    writeln('You answered it already')
    else begin
    writeln('Asking question #', QIndex);
    AnsweredAlready[QIndex] := true;
    end;
    end;
    until QIndex = 0;
    end;
    [/code]
Sign In or Register to comment.