Write a PL/SQL block to find out if a year is a leap year.

A leap year is divisible by 4, but not divisible by 100, or it is divisible by 400. For example, 2000 and 2004 are leap years, but 1900 and 2001 are not leap years. (Hint: The function MOD (n, d) divides n by d and returns the integer remainder from the operation)


```
SQL> DECLARE
2 year NUMBER(4) := &year_value;
3 BEGIN
4 IF (MOD(year,4)=0 AND MOD(year,100)!=0) OR MOD(year, 400)=0 THEN
5 DBMS_OUTPUT.PUT_LINE(year || ' is a leap year');
6 ELSE
7 DBMS_OUTPUT.PUT_LINE(year || ' is not a leap year');
8 END IF;
9 END;
10 /
Enter value for year_value: 1991
1991 is not a leap year

PL/SQL procedure successfully completed.

SQL> /
Enter value for year_value: 1900
1900 is not a leap year

PL/SQL procedure successfully completed.

SQL> /
Enter value for year_value: 2000
2000 is a leap year

PL/SQL procedure successfully completed.

SQL> /
Enter value for year_value: 2004
2004 is a leap year

PL/SQL procedure successfully completed.
```

Computer Science & Information Technology

You might also like to view...

A call inside the LATA is routed from a central office to a tandem office over

a. an interoffice trunk b. an intertoll trunk c. a tandem trunk d. a toll-connecting trunk

Computer Science & Information Technology

What are the data speeds for V.44/V.34 and V.92/V.90?

What will be an ideal response?

Computer Science & Information Technology

State whether each of the following is true or false. If false, explain why.

1) All virtual functions in an abstract base class must be declared as pure virtual functions. 2) Referring to a derived-class object with a base-class handle is dangerous. 3) A class is made abstract by declaring that class virtual. 4) If a base class declares a pure virtual function, a derived class must implement that function to become a concrete class. 5) Polymorphic programming can eliminate the need for switch logic.

Computer Science & Information Technology

A(n) ________ translates source code into an intermediate form of code, line by line.

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology