2 câu trả lời
Program tong;
Uses crt;
Var n , s , k: integer;
Begin
Write(‘ Nhap N:’);
Readln(N );
S := 0;
While ( N <> 0 ) do Begin
k := N mod 10;
N := N div 10;
S := S + k;
End;
Writeln( ‘Tong cac chu so cua ’,N,’ la :’, S);
Readln
End.
Program FNG;
Uses crt;
Var n,s: longint;
Begin
Clrscr;
Write('Nhap n: '); Readln(n);
s:=0;
While n<>0 do
Begin
s:=s+n mod 10;
n:=n div 10;
End;
Write('S = ',s);
Readln
End.
Câu hỏi trong lớp
Xem thêm