Lógica de Programación
case, until, for, pares, impares, primos, calculo de notas
program logicander;
uses wincrt;
var
opcion, i : integer;
respuesta : char;
ni, nii, prome : real;
nombre : string;
begin
WriteLn ( '1- Numeros pares' );
WriteLn ( '2- Numeros impares' );
WriteLn ( '3- Numeros primos' );
WriteLn ( '4- Calculo de notas' );
WriteLn ('');
WriteLn ( 'Ingrese una opcion' );
ReadLn (opcion);
case opcion of
1 : Begin
ClrScr;
Writeln('Numero Pares');
FOR i:=1 TO 10 DO
IF (i mod 2)=0 then
Writeln(i);
End;
2 : Begin
ClrScr;
Writeln('Numero Pares');
FOR i:=1 TO 10 DO
IF (i mod 2)=1 then
Writeln(i);
End;
3 : Begin
ClrScr;
Writeln('Numero Primos');
FOR i:=1 TO 10 DO
IF ((i mod 2)=1) and (i<>9) or (i=2) THEN
Writeln(i);
End;
4 : Begin
repeat
Begin
Writeln ( 'Ingrese el nombre del alumno' );
Readln (nombre);
Writeln ('');
writeln ( 'ingrese nota 1' );
readln (ni);
writeln ('');
writeln ( 'Ingrese nota 2' );
readln (nii);
prome:=(ni+nii)/2;
writeln ('');
writeln ( 'el promedio es: ', prome:5:2);
writeln ('');
writeln ( 'desea agregar otro S/N' );
readln (respuesta);
end;
until respuesta='N';
end;
end;
end.
Suscribirse a:
Comentarios (Atom)