This program demonstrates While, Do, and For loop counting using user-designated start, stop, and increment values.

Main Program
    Get Starting value
    Get Ending value
    Get Increment value
    Demonstrate While Loop
    Demonstrate Do Loop
    Demonstrate For Loop

Get Value
    Parameters:
        Label
    Process:
        Display prompt with label
        Get value
    Return Value:
        Value

Demonstrate While Loop
    Parameters:
        Start
        Stop
        Increment
    Process:
        Initialize count
        Loop while count < stop
            Display count
            Increment count
    Return Value:
        None

Demonstrate Do Loop
    Parameters:
        Start
        Stop
        Increment
    Process:
        Initialize count
        Loop
            Display count
            Increment count
            While count <= stop
    Return Value:
        None

Demonstrate For Loop
    Parameters:
        Start
        Stop
        Increment
    Process:
        Initialize count
        Loop for count from start to stop by increment
            Display count
    Return Value:
        None

License

Icon for the Creative Commons Attribution-ShareAlike 4.0 International License

Programming Fundamentals Copyright © 2018 by Authors and Contributors is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License, except where otherwise noted.

Share This Book