blob: f0fb1296c5ca1b2f02668fd123c2f16a14b1a28d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
program scanf_example2;
{$mode objfpc}{$H+}
uses
sysutils, gmp;
var
n, sqr: MPInteger;
s: string;
begin
write('Please enter an integer of any length: ');
readln(s);
z_init(n);
if mp_sscanf(pchar(s), '%Zd', n.ptr) = 1 then begin
sqr := n ** 2;
writeln(format('%s^2 = %s', [string(n), string(sqr)]));
end else
writeln('Failed to parse an integer from your input');
end.
|