PL/SQL Control Statement Exercises: Print 1st n numbers
PL/SQL Control Statement: Exercise-23 with Solution
Write a program in PL/SQL to print 1st n numbers.
DECLARE n number:= &first_n_number; BEGIN DBMS_OUTPUT.PUT_LINE ('The first '||n||' numbers are: '); for i in 1..n loop dbms_output.put(i||' '); END LOOP; dbms_output.new_line; END; /
Enter value for first_n_number: 10 old 2: n number:= &first_n_number; new 2: n number:= 10; The first 10 numbers are: 1 2 3 4 5 6 7 8 9 10 PL/SQL procedure successfully completed.
Improve this sample solution and post your code through Disqus
Previous: Write a program in PL/SQL using loop with CONTINUE WHEN statement.
Next: Write a program in PL/SQL to print 1st n numbers with a difference of 3 and starting from 1.
What is the difficulty level of this exercise?
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises