Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

What is wrong with this code?

+2 votes
asked May 20, 2020 by V P (210 points)
program Operadores_logicos;
    uses crt;
    var
    Respuesta_1,Respuesta_2:Integer;
    begin
    writeln ('¿Puedo ir a la fiesta?');
    writeln ('¿Sacaste la basura?');
    writeln ('Seleccione su respuesta');
    writeln ('1) si');
    writeln ('2) No');
    read (Respuesta_1);
    writeln ('Hiciste tu tarea?');
    writeln ('Seleccione su respuesta');
    writeln ('1) si');
    writeln ('2) No');
    read (Respuesta_2);
    if Respuesta_1 <2 and Respuesta_2 <2 then
    begin
    writeln ('Si puedes ir a la fiesta');
    end;           
    else
    begin
    writeln ('No puedes ir a la fiesta');
    end;
    repeat until keypressed;
end.

2 Answers

+1 vote
answered May 22, 2020 by Daniel Neudert (460 points)
selected May 27, 2020 by V P
 
Best answer
You should clearly define and separate your conditions with brackets. Further, before the "else" you don't need to end the code line with ";". Please check with:

program Operadores_logicos;
    uses crt;
    var
    Respuesta_1,Respuesta_2:Integer;
    begin
    writeln ('¿Puedo ir a la fiesta?');
    writeln ('¿Sacaste la basura?');
    writeln ('Seleccione su respuesta');
    writeln ('1) si');
    writeln ('2) No');
    read (Respuesta_1);
    writeln ('Hiciste tu tarea?');
    writeln ('Seleccione su respuesta');
    writeln ('1) si');
    writeln ('2) No');
    read (Respuesta_2);
    if (Respuesta_1 < 1) and (Respuesta_2 < 1) then
    begin
    writeln ('Si puedes ir a la fiesta');
    end           
    else
    begin
    writeln ('No puedes ir a la fiesta');
    end;
    repeat until keypressed;
end.
+1 vote
answered May 21, 2020 by M Gssnr (160 points)
It's been a long time since I wrote Pascal, but I THINK:

 the "end;" in your if statement should just be "end" (drop the semicolon).
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...