Răspuns :
Program SumaCifrelor;
var s,nr : integer;
begin
writeln('Introduceti numarul:');
readln(nr);
while nr<>0 do
begin
s:=s+nr mod 10;
nr:=nr div 10;
end;
writeln('Suma cifrelor numarului ',nr,' este:');
writeln(s);
end.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n,s=0;
scanf("%d",&n);
while (n!=0)
{
s=s+(n%10);
n=n/10;
}
printf("%d",s);
return 0;
}