Question #298817

Construct a pseudo code and flowchart which reads in two integer values. Then display all the numbers that is located between two numbers. If the first number entered is smaller than the second number entered, print all numbers in ascending order. On the other hand, if the first number entered is greater than the second number entered, print all numbers in descending order. Example: Input : 3 7 Output : 3 4 5 6 7 Input : 7 3 Output : 7 6 5 4 3


Expert's answer




function main()
    output "Enter the first number:"
    input firstNumber
    output "Enter the second number:"
    input secondNumber
    if firstNumber < secondNumber then
        loop i from firstNumber to secondNumber
            output i
        end loop
    else
        loop i from firstNumber to secondNumber step -1
            output i
        end loop
    end If
end function

LATEST TUTORIALS
APPROVED BY CLIENTS