# Introdução a Computação Soluções da aula prática 3

1.
PROGRAM TamanhoDasVariaveis;

Var bl: booelan;
by: byte;
i: integer;
w: word;
l: longint;
r: real;
d: double;
e: extended;
c: char;
s: string;

begin
WriteLn('boolean: ', SizeOf(bl), ' bytes');
WriteLn('byte: ', SizeOf(bt), ' bytes');
WriteLn('integer: ', SizeOf(i), ' bytes');
WriteLn('word: ', SizeOf(w), ' bytes');
WriteLn('longint: ', SizeOf(l), ' bytes');
WriteLn('real: ', SizeOf(r), ' bytes');
WriteLn('double: ', SizeOf(d), ' bytes');
WriteLn('extended: ', SizeOf(e), ' bytes');
WriteLn('char: ', SizeOf(c), ' bytes');
WriteLn('string: ', SizeOf(s), ' bytes');
end.

boolean: 1 bytes
byte: 1 bytes
integer: 2 bytes
word: 2 bytes
longint: 4 bytes
real: 6 bytes
double: 8 bytes
extended: 10 bytes
char: 1 byte
string: 256 bytes

 2a. PROGRAM TamanhoDasVariaveis; Var bl: booelan;     by: byte;     i: integer;     w: word;     l: longint;     r: real;     d: double;     e: extended;     c: char;     s: string; begin   WriteLn('boolean: ', bl);   WriteLn('byte: ', bt);   WriteLn('integer: ',i);   WriteLn('word: ', w);   WriteLn('longint: ', l);   WriteLn('real: ', r);   WriteLn('double: ', d);   WriteLn('extended: ', e);   WriteLn('char: ', c);   WriteLn('string: ', s); end. resultado do programa poderia ser: boolean: TRUE byte: 34 integer: -6589 word: 3256 longint: 0 real: 3.45927643E32 double: 5.111878091E103 extended: 9.9934512987E-204 char: % string: BjHGgy^tTr4RFgjOI()0iOolooiGvTR4@#4Erd BhHHGT&Yg%%90KJNhjJhHUY(7/&77676767767&77tyg6t NBHGuyFIt675&%7687/8788hKJjho9YuhPUy 2b. PROGRAM TamanhoDasVariaveis; Var bl: booelan;     by: byte;     i: integer;     w: word;     l: longint;     r: real;     d: double;     e: extended;     c: char;     s: string; begin   bl := FALSE;   bt := 0;   i := 0;   w := 0;   l := 0;   r := 0.0;   d := 0.0;   e := 0.0;   c := 'a';   s := 'ola';   WriteLn('boolean: ', bl);   WriteLn('byte: ', bt);   WriteLn('integer: ',i);   WriteLn('word: ', w);   WriteLn('longint: ', l);   WriteLn('real: ', r);   WriteLn('double: ', d);   WriteLn('extended: ', e);   WriteLn('char: ', c);   WriteLn('string: ', s); end. resultado do programa será: boolean: FALSE byte: 0 integer: 0 word: 0 longint: 0 real: 0 double: 0 extended: 0 char: a string: ola

3.

Var r: real;
i: longint;
s: string;

begin
r := 63.9;
s := 'Peter Stallinga';
i := 99999;
WriteLn(s:30, i:10, r:10:2);
end.

Peter Stallinga     99999     63.9

4.
PROGRAM Constante;

Var r1, r2: real;
Const E = 2.7;

begin
r1 := 63.9*E;
r2 := 1.0;
WriteLn(r1:0:4);
WriteLn(r2:0:4);
end.

5.
PROGRAM FullOfErrors;    (* faltava 'PROGRAM' *)

real: x,y,z;             (* o lugar de declarar as variaveis e antes 'begin' *)
(* a delaracao e: VAR nome: tipo; *)
CONST PI = 3.1415;       (* Pi nao e 1.6857 *)

begin
x := 3.0;              (* lado esquerde: tipo real, lado direito deve ser igual *)
y = 2.0*PI;            (* constantes com maiusculas *)
z := 1;                (* lado esquerdo: uma variavel, lado direito: expressao *)
writeln(x:0:3);        (* writeln com um n *)
end.