Play it for three times and we can get the final result.

My answer:

var
number, guess: integer;

begin
randomize;
number:= random(3)+1;
writeln('Wellcome to the game of snap.');
readlnln (guess);
if guess>number then begin writeln('It''s too big! Please try again.'); end
else
if guess<number then begin writeln('It''s too small! Please try again!'); end
else begin writeln ('CONGRATULATIONS, you have chosen the right number."); end;
until guess=number;
sleep(10000);
end.

Please help to make changes.

What do you think? :)

{
Question
 "Play it for three times and we can get the final result."
}
Program Solution01;
Var number,guess,i,counter:Integer;
Begin {main}
   Randomize;
   counter:=0;
   For i:=1 To 3 Do Begin {three times}
      number:=1+Random(3);{in every round,random number between 1 and 3}
      WriteLn('---------------------------------');
      WriteLn(i,'. Welcome to the game of snap.');
      Repeat
         Write('Give me a number between 1 and 3: ');
         ReadLn(guess);

         If (guess<number) Then Begin
            WriteLn('It''s too small!'+' Number was: ',number);
            if (i<>3) then WriteLn('Please try again!')
            Else WriteLn('Game Over.');
            Break;
         End;
         If (guess>number) Then Begin
            WriteLn('It''s too big!'+' Number was: ',number);
            if (i<>3) then WriteLn('Please try again!')
            Else WriteLn('Game Over.');
            Break;
         End;
         If (guess = number) Then Begin
            WriteLn('CONGRATULATIONS!!!!');
            if (i<>3) then WriteLn('You have chosen the right number!!!')
            Else WriteLn('Game Over.');
            counter:=counter+1;
            Break;{exit the loop}
         End;
      Until guess = number;
   End;
   WriteLn('---------------------------------');
   WriteLn;
   WriteLn('Your total points: ',counter,' of 3');
   WriteLn('---------------------------------');
   ReadLn;
End.

{
-= Note By FlamingClaw =-
All programs created by me  are written and tested
in Dev Pascal and/or Turbo Pascal 7.0
Of course working!
-= Created By FlamingClaw =-
-=2009.04.01=-
}
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.