-
Lenguaje
Pascal
-
Descripción
Existe un juguete fallado, el cual cuando es encendido y puesto en operación avanza inicialmente 5 cm y se detiene. Y cada vez que se levanta y se ubica nuevamente en el suelo avanza el doble del espacio anterior. De acuerdo a lo expuesto escriba un algoritmo que ingrese el número de veces que se levantará el juguete y entonces mostrar en total cuantos centímetros avanzará este.
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
program JugueteFallado;
uses crt;
var centimetros, i, n : integer;
begin
centimetros := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
if i=1 then
begin
centimetros := 5;
end
else
begin
centimetros := centimetros*2;
end;
writeln;
end;
writeln ('Valor de centimetros: ', centimetros);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var centimetros, i, n : integer;
begin
centimetros := 0;
write ('Ingresa el valor de n: ');
readln (n);
for i:=1 to n do
begin
writeln ('PROCESO ', i);
if i=1 then
begin
centimetros := 5;
end
else
begin
centimetros := centimetros*2;
end;
writeln;
end;
writeln ('Valor de centimetros: ', centimetros);
write ('Presiona una tecla para terminar . . . ');
readkey;
end.