I'm creating a calculator in PASCAL, I have already created the calculator but I don't want the program to end as soon as I give it one equation to do. What I want is to be able to loop my code over and over again by pressing a key (Y) and end the program when I press another key (N).
Sure, here's an example of how you can create a loop in your calculator code so that it continues to run until the user presses a specific key (such as "N"):
var continue: char; begin continue := 'Y'; while (continue = 'Y') do begin // your calculator code here writeln('Do you want to continue? (Y/N)'); readln(continue); end; end.
This will create a "while" loop that will continue to execute as long as the "continue" variable is equal to 'Y'. Inside the loop, you can place your existing calculator code, and then ask the user if they want to continue by typing "Y" or "N" using the "readln" command. If the user enters "N", the "continue" variable will be updated and the loop will be terminated, ending the program.