
Добавил:
bagiwow
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Паскаль / do9 / iriepas201 / Irie Pascal / samples / add
.pas program add(output);
(*
** This sample program adds up all the program arguments
** and prints out the sum
*)
var
sum, (* Stores the sum *)
i, (* Counts the program arguments *)
x, (* Stores the converted program arguments *)
err (* Indicates whether or not there was an error *)
: integer;
begin
sum := 0; (* initiaze the sum *)
for i := 1 to paramcount do
begin
val(paramstr(i), x, err); (* Convert program agument into an integer *)
if err <> 0 then
begin
writeln(paramstr(i), ' is not a valid integer');
halt
end;
sum := sum + x
end;
writeln('Sum is ', sum)
end.
(*
** This sample program adds up all the program arguments
** and prints out the sum
*)
var
sum, (* Stores the sum *)
i, (* Counts the program arguments *)
x, (* Stores the converted program arguments *)
err (* Indicates whether or not there was an error *)
: integer;
begin
sum := 0; (* initiaze the sum *)
for i := 1 to paramcount do
begin
val(paramstr(i), x, err); (* Convert program agument into an integer *)
if err <> 0 then
begin
writeln(paramstr(i), ' is not a valid integer');
halt
end;
sum := sum + x
end;
writeln('Sum is ', sum)
end.