Oracle PL/SQL - What is the output: Division operator precedence?

Question

What is the output of the following code?

DECLARE 
  salary      NUMBER := 60000; 
  commission  NUMBER := 0.10; 
BEGIN 

 
DBMS_OUTPUT.PUT_LINE('5 + 12 / 4 = ' || TO_CHAR(5 + 12 / 4)); 
DBMS_OUTPUT.PUT_LINE('12 / 4 + 5 = ' || TO_CHAR(12 / 4 + 5)); 
END; 
/ 

Note

Division has higher precedence than addition:

Demo

SQL>
SQL> DECLARE--  w  ww  . j a  va  2  s  .co  m
  2    salary      NUMBER := 60000;
  3    commission  NUMBER := 0.10;
  4  BEGIN
  5
  6
  7  DBMS_OUTPUT.PUT_LINE('5 + 12 / 4 = ' || TO_CHAR(5 + 12 / 4));
  8  DBMS_OUTPUT.PUT_LINE('12 / 4 + 5 = ' || TO_CHAR(12 / 4 + 5));
  9  END;
 10  /
5 + 12 / 4 = 8
12 / 4 + 5 = 8

PL/SQL procedure successfully completed.

SQL>

Related Quiz