0% found this document useful (0 votes)
16 views3 pages

Algorithms and Pseudocode Examples

The document outlines various algorithmic problems, pseudocode tasks, flowchart designs, control structures, loops, and dry-running exercises. It includes specific problems such as finding the largest number among three, calculating factorials, checking for palindromes, and determining leap years. Additionally, it covers programming tasks related to grades, day names, prime numbers, and digit sums.

Uploaded by

kenebeniceline
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)
16 views3 pages

Algorithms and Pseudocode Examples

The document outlines various algorithmic problems, pseudocode tasks, flowchart designs, control structures, loops, and dry-running exercises. It includes specific problems such as finding the largest number among three, calculating factorials, checking for palindromes, and determining leap years. Additionally, it covers programming tasks related to grades, day names, prime numbers, and digit sums.

Uploaded by

kenebeniceline
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

Algorithms

1. Problem: Write an algorithm to find the largest number among three given numbers.
o Inputs: Three numbers (A, B, C).
o Output: The largest number.
2. Problem: Design an algorithm to calculate the factorial of a number n.
o Input: A positive integer n.
o Output: The factorial of n.
3. Problem: Create an algorithm to check if a given number is a palindrome.
o Input: A positive integer.
o Output: "Yes" if the number is a palindrome; otherwise, "No."

Pseudocodes

4. Problem: Write a pseudocode to calculate the sum of all even numbers between 1 and
100.
o Output: Total sum of even numbers.
5. Problem: Create a pseudocode to reverse the digits of a given number.
o Input: An integer.
o Output: Reversed number.
6. Problem: Develop a pseudocode to determine whether a given year is a leap year.
o Input: A year.
o Output: "Leap year" or "Not a leap year."

Flowcharts

7. Problem: Draw a flowchart to calculate the area of a circle given its radius.
o Input: Radius.
o Output: Area of the circle.
8. Problem: Design a flowchart to determine whether a number is positive, negative, or
zero.
o Input: A number.
o Output: "Positive," "Negative," or "Zero."
9. Problem: Create a flowchart to print the Fibonacci sequence up to a given number n.
o Input: Limit n.
o Output: Fibonacci series up to n.

Control Structures
10. Problem: Write a program to determine the grade of a student based on the following
marks criteria:

 =90: A
 =80: B
 =70: C
 =60: D
 <60: F
 Input: Marks scored.
 Output: Corresponding grade.

11. Problem: Use a switch-case structure to display the name of the day based on a given
number (1 for Monday, 2 for Tuesday, etc.).

 Input: A number (1–7).


 Output: Day name.

Loops

12. Problem: Write a loop to print all prime numbers between 1 and 50.

 Output: Prime numbers.

13. Problem: Develop a program using a loop to calculate the sum of the digits of a number.

 Input: An integer.
 Output: Sum of its digits.

14. Problem: Write a program using a nested loop to print the following pattern:

*
**
***
****
*****

Dry Running

15. Problem: Dry-run the following pseudocode and write the output for n = 5:

Start
Input n
Sum ← 0
For i ← 1 to n
Sum ← Sum + i
EndFor
Output Sum
End

16. Problem: Dry-run the algorithm to find the maximum of three numbers using A = 10, B
= 25, C = 15.

 Algorithm:

Start
Input A, B, C
If A > B AND A > C Then
Max ← A
Else If B > C Then
Max ← B
Else
Max ← C
EndIf
Output Max
End

You might also like