Program určí ciferný súčet daného čísla

Delphi & Pascal (česká wiki)
Přejít na: navigace, hledání
Kategória: Zadania Pascal

Autor: Pheo
web: pascalsource.ic.cz

Program: Prevod.pas
Súbor exe: Prevod.exe

Program určí ciferný súčet daného čísla.
{ PREVOD.PAS                                     Copyright (c) Pheo }
{ Program určí ciferný súčet daného čísla.                          }
{                                                                   }
{ Datum:15.04.2003                             http://www.trsek.com }
 
program prevod;
uses crt;
var X:string;
    s,i,d:Integer;
begin
  Writeln('Zadaj cislo X ako retazec: ');
  Readln (X);
  s:=0;
  D:=length(X);
  for i:=1 to d do s:=s+ord(x[i])-48;
  writeln('Ciferny sucet je ', s);
  readln;
end.