Quick Test 8: Boolean Algebra / switch

1. What will be the output of the following program?
main()
{
  double a, b;
  double c = 10.0;

  a = 9.0;  b = 2.0*c;
  if ((a>0) || (b>0))
    printf("Fixe!");
  else
    printf(" Uma pena");
}

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

2.  What is wrong with the following program
main()
{
  double a;
  double c = 2;

  a = 3.0;
  switch (a+1.0)
   {
    case 1: printf("Fixe!\n");
        break;
    case c: 
         printf("Cool!\n");
         printf("Ingles");
        break;
    case 3: printf("Super!");
        break;
    default: printf("Language?\n");
   }
}

a) switch cannot contain expressions (a+1.0)
b) switch cannot have expressions of type float (a+1.0)
c) In the structure switch we cannot use variables (case c:)
d) Both b) and c)

3a. What will be the result of the Boolean calculation (41 | 35)?



3b. What will be the result of the Boolean calculation (41 & 6)?


3c. What will be the result of the Boolean calculation (41 && 6)?
4. 
     (3*4 + 12/6*i - j*2) 
is an example of

an expression
a condition
an assignment
an operation