PL/SQL Program to Check Number is Odd or Even

Here you will get pl/sql program to check number is odd or even.

A number is even if it is completely divisible by 2 otherwise it is odd.

 

PL/SQL Program to Check Number is Odd or Even

declare
	n number:=&n;

begin
	if mod(n,2)=0
	then
		dbms_output.put_line('number is even');
	else
		dbms_output.put_line('number is odd');
	end if;
end;
/

 

Output

Enter value for n: 7
old   2:        n number:=&n;
new   2:        n number:=7;
number is odd

5 thoughts on “PL/SQL Program to Check Number is Odd or Even”

  1. Hi fellas,
    I’m wondering if that works only or int numbers, I’ve tried for numbers with decimal digits and didn’t get the expected results. Do you know a simple solution for non-int numbers?

  2. Sananda Khadia

    Write a pl/SQL code block to enter a number and if the number it’s single digit to then display it’s in Roman form.

  3. Can you develop a PL/SQL program to check whether the inputted number by the user is even or odd without using simple If. If no, justify your answer and if yes, write the appropriate code using PL/SQL block with proper exceptions.

Leave a Comment

Your email address will not be published. Required fields are marked *