• Lenguaje

    Pascal

  • Descripción

    Simula el funcionamiento de una calculadora que realiza las operaciones básicas de SUMA, RESTA, MULTIPLICACIÓN y DIVISIÓN. El algoritmo debe mostrar un mensaje de ¿DESEA CONTINUAR[S/N]? El algoritmo se detiene si se presiona la letra [N].

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
27
28
29
30
31
32
33
34
35
program SumaRestaMultiplicacionYDivision;
uses crt;

var a, b, division, multiplicacion, resta : real;
var suma : real;
var tecla_repetir : char;
begin
    repeat
        clrscr;
        write ('Ingresa el valor de a: ');
        readln (a);
        write ('Ingresa el valor de b: ');
        readln (b);
        suma := a+b;
        resta := a-b;
        multiplicacion := a*b;
        if b=0 then
            begin
                division := 0;
            end
        else
            begin
                division := a/b;
            end;
        writeln ('Valor de division: ', division:0:6);
        writeln ('Valor de multiplicacion: ', multiplicacion:0:6);
        writeln ('Valor de resta: ', resta:0:6);
        writeln ('Valor de suma: ', suma:0:6);
        writeln;
        write (#168'Deseas repetir el proceso? (S/N): ');
        repeat
            tecla_repetir := readkey;
        until (tecla_repetir = 's') or (tecla_repetir = 'n') or (tecla_repetir = 'S') or (tecla_repetir = 'N');
    until (tecla_repetir <> 's') and (tecla_repetir <> 'S');
end.