Quick Test 6: Assignment, Input and Math

1. When we want to assign a value of 8.3 to a variable r we do this with

r = 8.3;
r := 8.3;
r == 8.3;.
8.3 -> r;

2. After the assignment of question 1, which of the following lines of C will produce 
   8.3000

printf(8.3000);
printf(6*r,4);
printf(r:6:4);
printf("%6.4f", r);

3. What is wrong with the following program?

main()
{
  float x;
  double c = 1.0;

  x*x = 2*c;
}

A constant cannot change a value
The left side of the = can only contain a (single) variable
Variable x is not well defined
The right side of = cannot contain expressions

4. What is the output of the next program

main()
{
  double x;
  double C = 1.0;

  x = C + 1.0;
  x = 2;
  x = x + 3.0;
  printf("%4.1f", x);
}

7.0
5.0
3.0
1.0

5. What is the result of the expression "33 / 2"?

1.5
16
16.5
1

6. What is the result of the expression "33 % 2"?

1.5
16
16.5
1

7. What is priority of the operators +,  * and (..)

first + then * then (..)
first * then + then (..)
first (..) then * then +
first (..) then + then *

8. What is the result of the expression 
  "1.0 + 2.0 * 3.0 - 6.0 / 2.0"?

4.0
1.5
14
9.0