Nội dung text Untitled document - 2024-09-13T222743.476.pdf
BEGIN IF score >= 90 THEN DBMS_OUTPUT.PUT_LINE('Grade: A'); ELSIF score >= 80 THEN DBMS_OUTPUT.PUT_LINE('Grade: B'); ELSIF score >= 70 THEN DBMS_OUTPUT.PUT_LINE('Grade: C'); ELSE DBMS_OUTPUT.PUT_LINE('Grade: D'); END IF; END; Explanation: ● IF score >= 90 THEN: Checks if the score is greater than or equal to 90. If true, it executes the first block of statements. ● ELSIF score >= 80 THEN: If the previous condition was false, this condition is checked. If true, the corresponding block is executed. ● ELSE: If none of the previous conditions were true, this block is executed. Exercise 1. Write a PL/SQL program that calculates the sum of all even numbers between 1 and 10, skipping odd numbers [Use CONTINUE statement] Answer: DECLARE sum_even NUMBER := 0; counter NUMBER := 1; BEGIN WHILE counter <= 10 LOOP IF MOD(counter, 2) <> 0 THEN CONTINUE; -- Skip the rest of the loop for odd numbers END IF; sum_even := sum_even + counter; counter := counter + 1; END LOOP; Practicalkida.com