0% found this document useful (0 votes)
5 views2 pages

PLSQL Algorithms

The document outlines several PL/SQL algorithms including Palindrome, Prime Number, Even or Odd, Perfect Number, Simple Calculator, Factorial, and Fibonacci Series. Each algorithm consists of a series of steps starting from reading input to producing output based on specific conditions. These algorithms serve as foundational programming concepts for various mathematical and logical operations.

Uploaded by

John Paul
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

PLSQL Algorithms

The document outlines several PL/SQL algorithms including Palindrome, Prime Number, Even or Odd, Perfect Number, Simple Calculator, Factorial, and Fibonacci Series. Each algorithm consists of a series of steps starting from reading input to producing output based on specific conditions. These algorithms serve as foundational programming concepts for various mathematical and logical operations.

Uploaded by

John Paul
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PL/SQL Algorithms

1. Palindrome Algorithm
1. Start the program.
2. Read the input string or number.
3. Initialize an empty string variable for the reverse.
4. Reverse the string using a loop.
5. Compare the reversed string with the original.
6. If both are equal → print “Palindrome”, else print “Not Palindrome”.
7. Stop.

2. Prime Number Algorithm


1. Start the program.
2. Read the number n.
3. If n <= 1, print “Not Prime” and stop.
4. Initialize flag := 0.
5. Loop i from 2 to n/2:
If n MOD i = 0, set flag := 1 and exit loop.
6. If flag = 0, print “Prime”, else print “Not Prime”.
7. Stop.

3. Even or Odd Algorithm


1. Start the program.
2. Read the number n.
3. If n MOD 2 = 0 → print “Even”.
4. Else → print “Odd”.
5. Stop.

4. Perfect Number Algorithm


1. Start the program.
2. Read the number n.
3. Initialize sum := 0.
4. Loop i from 1 to n/2:
If n MOD i = 0, then sum := sum + i.
5. If sum = n → print “Perfect Number”, else print “Not Perfect”.
6. Stop.

5. Simple Calculator Algorithm


1. Start the program.
2. Read two numbers a and b.
3. Read an operator (+, -, *, /).
4. If + → result = a + b
If - → result = a - b
If * → result = a * b
If / → check if b = 0; if not, result = a / b
Otherwise → print “Invalid Operator”.
5. Print the result.
6. Stop.

6. Factorial Algorithm
1. Start the program.
2. Read the number n.
3. Initialize fact := 1.
4. Loop i from 1 to n:
fact := fact * i.
5. Print fact.
6. Stop.

7. Fibonacci Series Algorithm


1. Start the program.
2. Read the number of terms n.
3. Initialize a := 0, b := 1.
4. Print a and b.
5. Loop from 3 to n:
c := a + b
Print c
a := b, b := c.
6. Stop.

You might also like