Im failing to see what Ive done wrong, the syntax is right but the program wont run for me when I enter in a the else statement works tho....

program Word (input, output);
uses crt;
   var
      number : integer;
      letter: string;
   begin
      {------------Introduction & Setup------------------}
      clrscr;
      {------VERY User-Friendly------}
      Repeat
         writeln('Whats the right letter? ');
         readln(number);
         str(number,letter);
         if (letter ='a') then
            writeln('Correct Answer ')
         else
            writeln(' a needs to be entered');
      Until (letter = 'a');
      {-------------------Printing Results------------------}
      writeln('The answer is ', letter);
      readln;
   end.

Any ideas? Im guessing its something stupid, I just cant seem to see it at the moment.

You didn't say what Pascal you are using, but typically readln expects a text variable and you are passing an integer. If the point is to read in an ASCII code and then print out the character, you need to read in the text, convert it to an integer and then convert the integer to the character.

Im using Free Pascal and thanks I hadnt noticed that.

There was another work around that I did with just setting the value as string as when a number is entered the program doesnt crash unlike with the reverse of a string being entered when the variable is an integer.

This is the solution I came up with a few minutes ago....

program Word (input, output);
uses crt;
   var
      letter: string;
   begin
      {------------Introduction & Setup------------------}
      clrscr;
      {------VERY User-Friendly------}
      Repeat
         writeln('Whats the right letter? ');
         readln(letter);
         if (letter = 'a') OR (letter = 'b') then
            writeln('Correct Answer ')
         else
            writeln(' a needs to be entered');
      Until (letter =UPCASE('a')) OR (letter = 'b');
      {-------------------Printing Results------------------}
      writeln('The answer is ', letter);
      readln;
   end.
This question has already been answered. Start a new discussion instead.