Quick Test 9: Boolean Algebra / Case ... Of



 
 

1. What will be the output of the following program
PROGRAM Test;

Var a, b: real;
Const c = 10.0;

begin
  a := 9.0;  b := 2.0*c;
  if (a>0) XOR (b>0) then
    Write('Fixe!')
  else
    Write(' Uma pena');
end.

Fixe!
Fixe! Uma pena
Uma pena
the program doesn't have output!

2.  What is wrong with the following program
PROGRAM Test;

Var a: real;
Const C = 2;

begin
  a := 3.0;
  Case a+1.0 Of
    1: Write('Fixe!');
    C: begin
         WriteLn('Cool!');
         WriteLn('Ingles');
       end;
    3: Write('Super!');
    else Write('Language?');
  end;
end.

Case .. Of cannot contain expressions (a+1.0)
Case ... Of cannot have expressions of type real (a+1.0)
In the structure Case ... Of we cannot use constants (C)
In the structure Case ... Of we cannot use else

3. What will be the result of the Boolean calculation (43 AND 33)?
 
 


 

4. 
     (3*4 + 12/6*i - j*2) 
is an exemplo of

an expression
a condition
an assignment
an operation