改错题

时间:2024-06-26 19:03:31 资料大全 我要投稿
  • 相关推荐

改错题

改错题(共4道)
1. 指出下列代码错误并说明原因:
Var
I:Integer;(超出范围)
L:Long;
Begin
L:=32768;
I:=L;
End.

2. 指出下列代码错误并说明原因:
if n>37.5 then
AmountEarned:=(n-37.5)*HourlyRate*1.5+37.5*HourlyRate; (没有定义n, AmountEarned, HourlyRate)
else
AmountEarned:= n*HourlyRate;

3. 指出下列代码错误并说明原因:
while (total<max) and (sum<=max) and (sum<total)
do statement1;

4. 指出下列代码错误并说明原因:
procedure Tform1.TestBtnClick(Sender:Tobject);
var z,y,x:integer;
begin
x:=100;
y:=0;
try
z:=x div y;
except
on EdivByZero
do begin
z:=-1;
MessageDlg(\'Z\'+IntToStr(z),mtInformation,[mbOK],0);
end
End;