EJERCICIO
1:
PROGRAM
EJER02;
USES
CRT;
VAR
x,y:INTEGER;
VAR
suma,rest,mult,divi:INTEGER;
BEGIN
x:=10;
y:=2;
suma:=x
+ y;
rest:=x
- y;
mult:=x
* y;
divi:=x
div y;
ClrScr;
WRITE('SUMA:');
WRITELN(suma);
WRITE('RESTA:');
WRITELN(rest);
WRITE('MULTIPLICACION:');
WRITELN(mult);
WRITE('DIVISION:');
WRITELN(divi);
END.
EJERCICIO
EJECUTADO:
Compiling
the source code....
$fpc -v0 EJER02.pas 2>&1
$fpc -v0 EJER02.pas 2>&1
Free Pascal Compiler version 2.6.2 [2013/02/16] for x86_64 Copyright (c) 1993-2012 by Florian Klaempfl and others /usr/bin/ld: warning: link.res contains output sections; did you forget -T?
Executing the program....
$EJER02
SUMA:12 RESTA:8 MULTIPLICACION:20 DIVISION:5
EXPLICACIÓN:
El
ejercicio comienza donde pone program ejer02 y termina en end.
Seguidamente vemos USES CRT que nos permitirá borrar la pantalla
inicial. Después nos presenta las variables que va a utilizar, a las
cuales da dos valores diferentes uno a x (x= 10) y otro a y (y= 2). Y
finalmente, establece las condiciones de: suma entre ambas por ello
al lado de suma pone un 12; resta, donde encontramos un 8;
multiplicación, donde hay un 20; y por último división, donde
vemos un 5. Otra instrucción que encontramos es ClrScr
EJERCICIO
2:
PROGRAM
EJER04;
USES
CRT;
VAR
base,altura:REAL;
VAR
area:REAL;
BEGIN
base:=7;
altura:=4;
area:=(base
* altura) / 2;
ClrScr;
WRITE
('AREA DEL TRIANGULO: '); WRITE (area:5:2);
{:5:2
sirve para dar el formato de salida al numero, 5 posiciones y 2
decimales}
END.
EJERCICIO
EJECUTADO:
Compiling
the source code....
$fpc -v0 EJER04.pas 2>&1
$fpc -v0 EJER04.pas 2>&1
Free Pascal Compiler version 2.6.2 [2013/02/16] for x86_64 Copyright (c) 1993-2012 by Florian Klaempfl and others /usr/bin/ld: warning: link.res contains output sections; did you forget -T?
Executing the program....
$EJER04
AREA DEL TRIANGULO: 14.00
