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 and range and the task is to display all the numbers whose sum of digits is equal to the given number.
Input: x = 23
Output: 599 689 698 779 788 797 869 878 887 896 959 968 977 986 995
(Note: range->1 to 999)
Output: 39 48 57 66 75 84 93
(Note: range->1 to 100)
Approach is to take a number, find all the possible numbers in the given range and sum all the digits of number and if sum of digits is equal to the number, then print that number.
Below it’s implementation:
799 889 898 979 988 997
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.