O'Reilly logo

Oracle® PL/SQL® Interactive Workbook, Second Edition by Elena Silvestrova, Benjamin Rosenzweig

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 1 Programming Concepts

1)Create the following structure: Based on the value of a number, determine if it is even or odd. Hint: Before you decide how to define even and odd numbers, you should decide what structure must be used to achieve the desired results.
A1: Answer: Your answer should look similar to the following:
IF MOD(NUMBER, 2) = 0 
   DISPLAY 'THIS NUMBER IS EVEN' 
IF MOD(NUMBER, 2) != 0 
   DISPLAY 'THIS NUMBER IS ODD' 

In this example, you are using the selection structure because a decision whether a number is even or odd must be made. This decision can be made with the help of the built-in function MOD. This function returns the remainder of the NUMBER divided by 2. If a number is divisible by 2 (in other words, there is no remainder), ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required