• Lenguaje

    Pascal

  • Descripción

    Pide un número entero positivo, calcula la cifra inversa y muestra si es capicua

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
program prog_inverso;
uses crt;

var numero, inverso, residuo: longint;
var tecla : char;
begin
    inverso := 0;
    write ('Ingrese un n'#163'mero: ');
    readln (numero);
    residuo := numero;
    while residuo > 0 do
        begin
            inverso := inverso * 10 + residuo mod 10;
            residuo := residuo div 10;
        end;
    writeln (#10#13'Valor del n'#163'mero inverso: ', inverso);
    write ('El n'#163'mero ', numero, ' ');
    if numero = inverso then
        write ('s'#161)
    else
        write ('no');
    writeln (' es capicua.'#10#13);
    write ('Presione una tecla para terminar . . . ');
    tecla := readkey;
end.