pascal algorithm with an error

Asked

Viewed 36 times

-1

I made this algorithm but it does not run, an error appears, "This is not expected":

Program valormaior_oumenor ;
    var
    valornicial, valorfinal:integer;
Begin
    writeln('Digite um valor ');
    read(valorinicial);
    writeln('Digite outro valor ');
    read(valorfinal);
    if (valorinicial>valorfinal) then
        while (valorinicial>=valorfinal) do
            writeln('valorinicial')
            valorinicial:=valorinicial+1
    else
        while  (valorinicial<=valorfinnal) do
        writeln(valorfinal)
        valorfinal:=valorinicial-1

End.

1 answer

3

Missing Begin and end for if and some variables were written different from declaration.

program valormaior_oumenor ;
Uses Crt;
    var
    valorinicial, valorfinal:integer;
begin
    writeln('Digite um valor ');
    read(valorinicial);
    writeln('Digite outro valor ');
    read(valorfinal);
    if (valorinicial>valorfinal) then
    begin
        while (valorinicial>=valorfinal) do
        begin  
          writeln('valorinicial');
          valorinicial:=valorinicial+1;
        end
    end    
    else
    begin
        while  (valorinicial<=valorfinal) do
        writeln(valorfinal);
        valorfinal:=valorinicial-1;
    end;
end.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.