Prerequisite- PL/SQL Introduction
In PL/SQL code groups of commands are arranged within a block. It groups together related declarations or statements. In declare part, we declare variables and between begin and end part, we perform the operations.
Given a number N, the task is to display all the even numbers and their sum from 1 to N.
Input: N = 3 Output: 2 Sum = 2 Input: N = 5 Output: 2, 4 Sum = 6
Approach is to initialize a number num with 2 and keep incrementing it by 2 until num is <= N.
Below is its implementation:
2 4 Sum of even numbers is 6
- Difference between SQL and PLSQL
- Print all odd numbers and their sum from 1 to n in PL/SQL
- Print Patterns in PL/SQL
- Print pyramid of GeeksforGeeks in PL/SQL
- Print different star patterns in SQL
- How to print duplicate rows in a table?
- Sum Of Two Numbers in PL/SQL
- GCD of two numbers in PL/SQL
- Swap two numbers in PL/SQL
- Sum and average of three numbers in PL/SQL
- Convert the given numbers into words in Pl/SQL
- Finding sum of first n natural numbers in PL/SQL
- Swap two numbers in PL/SQL without using temp
- Greatest number among three given numbers in PL/SQL
- Display Sequence of Numbers in SQL Using LEVEL
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.