Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
330 B
1
Indexable
Never
PARAMETERS: p_number TYPE i.

DATA: lv_number TYPE i,
      lv_digit  TYPE i,
      lv_sum    TYPE i.

lv_number = p_number.
lv_sum = 0.

WHILE lv_number > 0.
  lv_digit = lv_number MOD 10.
  lv_sum = lv_sum + lv_digit.
  lv_number = lv_number / 10.
ENDWHILE.

WRITE: 'Suma cyfr liczby', p_number, 'wynosi', lv_sum.
Leave a Comment