PL/SQL Control Statement Exercises: Check whether a number is prime or not using goto statement with for loop
PL/SQL Control Statement: Exercise-28 with Solution
Write a program in PL/SQL to check whether a number is prime or not using goto statement with for loop.
DECLARE msg VARCHAR2(30); n PLS_INTEGER := 83; BEGIN FOR i in 2..ROUND(SQRT(n)) LOOP IF n MOD i = 0 THEN msg := ' is not a prime number'; GOTO when_prime; END IF; END LOOP; msg := ' is a prime number'; <
> DBMS_OUTPUT.PUT_LINE(TO_CHAR(n) || msg); END; /
83 is a prime number PL/SQL procedure successfully completed.
Improve this sample solution and post your code through Disqus
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework