Board index » delphi » Pascal problem password prog

Pascal problem password prog

What did I wrong ????
Error message   Type mismatch  at the line with UNTIL in it

Program wachtwoord;
uses crt;
var password,teller,a,b,c : integer;
Procedure som;
        begin
             writeln('Geef uw eerste getal in');
             readln(b);
             writeln('Geef uw tweede getal in');
             readln(c);
             writeln('De som van ingegeven getallen is ',b+c);
        end;
{Hoofdprogramma}
Begin
     teller:=0;
     write('Geef uw password in');
     readln(a);
     repeat
           password := a;
     teller := teller + 1;
     until (password = 'hallo') or (teller = 3);
     if password = 'hallo' then som
     else write ('Sorry, wrong password');
End.

 

Re:Pascal problem password prog


Quote
"Marc Claeys" <marc.clae...@pandora.be> wrote in message

news:A2%V6.33389$mR5.4121244@afrodite.telenet-ops.be...

Quote
> What did I wrong ????
> Error message   Type mismatch  at the line with UNTIL in it
> var password,teller,a,b,c : integer;
[...]
>      until (password = 'hallo') or (teller = 3);

You have declared "password" as an integer. This means the compiler
expects "password" to be something like 47, not something like 'hallo'.
You should declare "password" as a string.

var
  password: string;
  teller, a, b, c: integer;

--
The Scarlet Manuka

Re:Pascal problem password prog


'a' as well as 'password' should be string also if you are leaving the
program this way
but the 'password := a'  isn't really needed

in otherwords

Program wachtwoord;
uses crt;

var password,teller,a,b,c : integer;          <---- remove 'a,'
var password,teller,b,c : integer;

Procedure som;
        begin
             writeln('Geef uw eerste getal in');
             readln(b);
             writeln('Geef uw tweede getal in');
             readln(c);
             writeln('De som van ingegeven getallen is ',b+c);
        end;
{Hoofdprogramma}
Begin
     teller:=0;
     write('Geef uw password in');
     readln(a);               <-- change to 'readln(password);'
     repeat
           password := a;     <-- delete this line
     teller := teller + 1;
     until (password = 'hallo') or (teller = 3);
     if password = 'hallo' then som
     else write ('Sorry, wrong password');
End.

Quote
The Scarlet Manuka wrote:

> "Marc Claeys" <marc.clae...@pandora.be> wrote in message
> news:A2%V6.33389$mR5.4121244@afrodite.telenet-ops.be...
> > What did I wrong ????
> > Error message   Type mismatch  at the line with UNTIL in it

> > var password,teller,a,b,c : integer;
> [...]
> >      until (password = 'hallo') or (teller = 3);

> You have declared "password" as an integer. This means the compiler
> expects "password" to be something like 47, not something like 'hallo'.
> You should declare "password" as a string.

> var
>   password: string;
>   teller, a, b, c: integer;

Re:Pascal problem password prog


The scarlet manuka en pluzer, thanks for the help

Other Threads