Prerequisite – PL/SQL introduction
In PL/SQL code groups of commands are arranged within a block. A block group 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 odd numbers from 1 to N and their sum.
Input: 3 Output: 1, 3 Input: 5 Output: 1, 3, 5
Approach is to initialize a num with 1 and sum with 0 and keep incrementing num by 2 and sum by num until num <= N.
1 3 5 Sum of all odd numbers is 9
- Print all even numbers from 1 to n in PL/SQL
- Print all the prime numbers between 'm' and 'n' in PL/SQL
- PLSQL | CHR Function
- Difference between SQL and PLSQL
- PLSQL | TAN Function
- PLSQL | LEAST Function
- PLSQL | COS Function
- PLSQL | LN Function
- PLSQL : || Operator
- PLSQL | MOD Function
- PLSQL | ABS Function
- PLSQL | SIN Function
- PLSQL | LOG Function
- PLSQL | EXP Function
- PLSQL | CONVERT Function