Pascal/Turbo Pascal - ejercicio pascal

 
Vista:

ejercicio pascal

Publicado por Davo (26 intervenciones) el 20/11/2012 23:32:12
hola, alguien puede ayudarme con este ejercicio?


Escriba una expresión selectiva múltiple en la que se muestre por pantalla:

• El valor de la variable selector si esta variable se corresponde con un número entre 1 y 5.

• El mensaje “el número no está entre 1 y 5”, en caso contrario.


Creo que seria asi pero al compilarlo me da muchos errores

program numeros_del_uno_al_cinco;

var
numero: integer;

begin
write ('Introduzca un numero del 1 al 5: ');
read(numero);


case ( numero) of
'1': writeln ('Este numero esta entre el 1 y el 5');
'2' : writeln ('Este numero esta entre el 1 y el 5');
'3': writeln ('Este numero esta entre el 1 y el 5');
'4': writen ( 'Este numero esta entre el 1 y el 5');
'5':writen ('Este numero esta entre el 1 y el 5');
else
writen ( 'El numero no esta entre el 1 y el 5');
end.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

ejercicio pascal

Publicado por davo (26 intervenciones) el 21/11/2012 17:52:56
ya lo tengo, ya encontre el fallo, pongo aqui el codigo correcto por si le sirve a alguien.
program numeros;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var
num:integer;
 
 
begin
writeln('Introduce un numero del 1 al 5: ');
readln(num);
 
case (num) of
 
1:writeln('Este numero esta entre 1 y 5');
2:writeln('Este numero esta entre 1 y 5');
3:writeln('Este numero esta entre 1 y 5');
4:writeln('Este numero esta entre 1 y 5');
5:writeln('Este numero esta entre 1 y 5');
 
else
writeln('Este numero no esta entre 1 y 5 , vuelva a intentarlo por favor');
readln;
end;
 end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar

ejercicio pascal

Publicado por ramon (2158 intervenciones) el 21/11/2012 18:50:25
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
{Mira un ejemplo a ver si ayuda}
 
program menus;
 uses
    crt;
 var
    tec : char;
  procedure marcador(x, y : integer; act : boolean);
  begin
      if act = true then
      begin
      gotoxy(x - 1,y - 1);write('ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿');
          gotoxy(x - 1,y);write('³');
          gotoxy(x + 20,y);write('³');
      gotoxy(x - 1,y + 1);write('ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ');
      end
    else
      begin
      gotoxy(x - 1,y - 1);write('                      ');
          gotoxy(x - 1,y);write(' ');
          gotoxy(x + 20,y);write(' ');
      gotoxy(x - 1,y + 1);write('                      ');
      end
  end;
 
  procedure otromenu;
  var
     opci2 : integer;
     termi : boolean;
     x2, y2 : integer;
     pul : char;
  begin
      clrscr;
      termi := false;
      opci2 := 1;
      x2 := 30;
      y2 := 4;
    repeat
      gotoxy(30,2);write('*****  Menu Dos *****');
      gotoxy(30,4);write('Multiplicar');
      gotoxy(30,6);write('Dividir');
      gotoxy(30,8);write('Salir');
      marcador(x2,y2,true);
      gotoxy(30,10);write('  Teclas [ ',chr(24),' ',chr(25),' ] y Enter');
    repeat
      pul := readkey;
      marcador(x2,y2,false);
      if pul = #72 then
      begin
         y2 := y2 - 2;
      if y2 < 4 then
      y2 := 4;
      opci2 := opci2 - 1;
      if opci2 < 1 then
      opci2 := 1;
   end;
   if pul = #80 then
   begin
       y2 := y2 + 2;
      if y2 > 8 then
      y2 := 8;
      opci2 := opci2 + 1;
      if opci2 > 3 then
      opci2 := 3;
   end;
   marcador(x2,y2,true);
   until pul = #13;
  case opci2 of
 1 : begin
         clrscr;
         writeln(' La multiplicacion de 5 * 3 sera = ',5 * 3);
         readkey;
         end;
 2 : begin
         clrscr;
         writeln(' La division de 59 / 7 sera = ',59 / 7:0:2);
         readkey;
         end;
 3 : termi := true;
  end;
   until termi = true;
   clrscr;
  end;
 
  procedure menu;
  var
    opci, x1, y1 : integer;
    sal : boolean;
  begin
     x1 := 4;
     y1 := 3;
     opci := 1;
     sal := false;
     repeat
     clrscr;
     gotoxy(4,1);write('*****  Menu General *****');
     gotoxy(4,3);write('Suma');
     gotoxy(4,5);write('Resta');
     gotoxy(4,7);write('Otro menu');
     gotoxy(4,9);write('Salir');
     marcador(x1,y1,true);
     gotoxy(4,11);write('  Teclas [ ',chr(24),' ',chr(25),' ] y Enter');
   repeat
     tec := readkey;
     marcador(x1,y1,false);
   if tec = #72 then
   begin
      y1 := y1 - 2;
      if y1 < 3 then
      y1 := 3;
      opci := opci - 1;
      if opci < 1 then
      opci := 1;
   end;
   if tec = #80 then
   begin
       y1 := y1 + 2;
      if y1 > 9 then
      y1 := 9;
      opci := opci + 1;
      if opci > 4 then
      opci := 4;
   end;
   marcador(x1,y1,true);
   until tec = #13;
   case opci of
  1 : begin
         clrscr;
         writeln(' La suma de 10 + 34 sera = ',10 + 34);
         readkey;
         end;
  2 : begin
          clrscr;
          writeln(' La resta de 108 - 74 sera = ',108 - 74);
          readkey;
          end;
  3 : otromenu;
  4 : sal := true;
    end;
     until sal = true;
   end;
 
  begin
      clrscr;
      menu;
  end.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar