-
Lenguaje
Pascal
-
Descripción
Muestre la suma, la resta, la división y la multiplicación de dos números. En el caso de la resta, se debe restar siempre el número menor del mayor. En el caso de la división, no se podrá efectuar si el segundo número es 0.
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
36
37
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
36
37
program SumaRestaDivisionYMultiplicacion;
uses crt;
var a, b, division, multiplicacion, resta : real;
var suma : real;
begin
write ('Ingresa el valor de a: ');
readln (a);
write ('Ingresa el valor de b: ');
readln (b);
suma := a+b;
multiplicacion := a*b;
if a>b then
begin
resta := a-b;
end
else
begin
resta := b-a;
end;
if b=0 then
begin
division := 0;
writeln ('No se puede efectuar la divisi'#162'n.');
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 ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var a, b, division, multiplicacion, resta : real;
var suma : real;
begin
write ('Ingresa el valor de a: ');
readln (a);
write ('Ingresa el valor de b: ');
readln (b);
suma := a+b;
multiplicacion := a*b;
if a>b then
begin
resta := a-b;
end
else
begin
resta := b-a;
end;
if b=0 then
begin
division := 0;
writeln ('No se puede efectuar la divisi'#162'n.');
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 ('Presiona una tecla para terminar . . . ');
readkey;
end.