CONST
N = 3;
VAR
num: REAL;
p, k, i, s: INTEGER;
nStr, kStr: STRING;
BEGIN
readln(num);
Str(num, nStr);
p:= Pos('.', nStr);
kStr:= copy(nStr, p + 1, N);
k:= StrToInt(kStr);
s:= 0;
WHILE (k <> 0) DO
s:= s + (k mod 10);
k:= k div 10;
END;
writeln(s);
END.
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
CONST
N = 3;
VAR
num: REAL;
p, k, i, s: INTEGER;
nStr, kStr: STRING;
BEGIN
readln(num);
Str(num, nStr);
p:= Pos('.', nStr);
kStr:= copy(nStr, p + 1, N);
k:= StrToInt(kStr);
s:= 0;
WHILE (k <> 0) DO
BEGIN
s:= s + (k mod 10);
k:= k div 10;
END;
writeln(s);
END.