07-25-2023, 09:43 AM
program ExceptionHandlingExample;
var
num1, num2, result: Integer;
begin
try
Write('Enter the first number: ');
ReadLn(num1);
Write('Enter the second number: ');
ReadLn(num2);
if num2 = 0 then
raise Exception.Create('Division by zero is not allowed.');
result := num1 div num2;
WriteLn('Result: ', result);
except
on E: Exception do
WriteLn('Exception caught: ', E.Message);
end;
end.
var
num1, num2, result: Integer;
begin
try
Write('Enter the first number: ');
ReadLn(num1);
Write('Enter the second number: ');
ReadLn(num2);
if num2 = 0 then
raise Exception.Create('Division by zero is not allowed.');
result := num1 div num2;
WriteLn('Result: ', result);
except
on E: Exception do
WriteLn('Exception caught: ', E.Message);
end;
end.
Also follow me on Youtube for videos about video games:
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos
https://www.youtube.com/channel/UCxfkGVU...2mQ/videos