05 Pseudocode Programs

Here are pseudocode examples for five basic programming tasks:

  1. Pseudocode for Sum of Two Numbers: This pseudocode calculates the sum of two numbers.
    Input: two numbers, num1 and num2
    Result: the sum of num1 and num2
    sum = num1 + num2
    Display sum
    

     

  2. Pseudocode for Finding the Maximum of Two Numbers: This pseudocode finds and displays the larger of two numbers.
    Input: two numbers, num1 and num2
    Result: the maximum of num1 and num2
    if num1 > num2
        Display num1
    else
        Display num2
    

     

  3. Pseudocode for Counting from 1 to N: This pseudocode counts from 1 to N and displays each number.
    Input: a positive integer N
    Result: counting from 1 to N
    set count to 1
    while count <= N
        Display count
        increment count by 1
    

     

  4. Pseudocode for Calculating Factorial: This pseudocode calculates the factorial of a given number.
    Input: a non-negative integer n
    Result: n factorial
    set factorial to 1
    for i from 1 to n
        multiply factorial by i
    Display factorial
    

     

  5. Pseudocode for Simple Loop: This pseudocode demonstrates a simple loop that prints a message multiple times.
    Input: a positive integer N
    Result: repeating a message N times
    set count to 1
    while count <= N
        Display "Hello, World!"
        increment count by 1
    

     

These pseudocode examples cover common programming tasks like arithmetic operations, conditional statements, loops, and mathematical calculations. They provide a high-level representation of the logic needed to solve these tasks and can serve as a starting point for implementing actual code in a specific programming language.

Leave a comment