-
Lenguaje
Pascal
-
Descripción
Dado como dato una variable X de tipo entero, obtenga el resultado de la función Y, de manera que:
Y = 100X Cuando X<0
Y = 2X+5 Cuando 0<=X<3
Y = 100/X Cuando 3<=X<=6
Y = 0 Para cualquier otro valor.
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 FuncionY;
uses crt;
var X, Y : integer;
begin
write ('Ingresa el valor de X: ');
readln (X);
Y := 0;
if X<0 then
begin
Y := 100*X;
end;
if (0<=X) and (X<3) then
begin
Y := 2*X+5;
end;
if (3<=X) and (X<=6) then
begin
Y := 100 div X;
end;
writeln ('Valor de Y: ', Y);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.
uses crt;
var X, Y : integer;
begin
write ('Ingresa el valor de X: ');
readln (X);
Y := 0;
if X<0 then
begin
Y := 100*X;
end;
if (0<=X) and (X<3) then
begin
Y := 2*X+5;
end;
if (3<=X) and (X<=6) then
begin
Y := 100 div X;
end;
writeln ('Valor de Y: ', Y);
writeln;
write ('Presiona una tecla para terminar . . . ');
readkey;
end.