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
- Print all odd numbers and their sum from 1 to n in PL/SQL
- Print all the prime numbers between 'm' and 'n' in PL/SQL
- PLSQL | ABS Function
- PLSQL | SIN Function
- PLSQL : || Operator
- PLSQL | EXP Function
- PLSQL | LN Function
- PLSQL | LOG Function
- PLSQL | CHR Function
- PLSQL | COS Function
- PLSQL | TAN Function
- Difference between SQL and PLSQL
- PLSQL | MOD Function
- PLSQL | LEAST Function
- PLSQL | CONCAT Function