C++:
#include
using namespace std;
int main()
{
int n;
do
{
cout <<"N = ";<br> cin >>n;
}
while (n<100 || n>999);
int sum = 0;
while (n!=0)
{
sum+=n%10;
n/=10;
}
cout <<sum <<endl;<br> return 0;
}
Pascal:
var n,sum:integer;
begin
readln (n);
sum:=0;
while (n<>0) do
begin
sum:=sum+(n mod 10);
n:=n div 10;
end;
writeln (sum);
end.