TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Flowgorithm

Flowgorithm While Loop Statement

Flowgorithm

Overview

In this tutorial, we will learn about the Flowgorithm While Loop Statement. The Flowgorithm tool offers three loop structures for repetitive statements in the flowcharts. The Looping structures are:

  • While Loop
  • For Loop
  • Do While Loop

 

Loops in Flowgorithm

While Loop

The While loop statement is a repetition structure and is an indefinite loop. While loop structure is used when we don’t know how many iterations we need. When we want to loop until some condition is met etc.

While loop construct is a condition-controlled loop and is a pre-test loop structure. The loop condition is checked before executing the loop statements.

Add While Loop

To add a While loop construct, right-click the mouse on the control line and choose the While symbol/shape.

 

While Loop Flowgorithm

 

Double click on the While symbol to provide the Boolean expression in the While properties window. For each iteration, the Boolean expression is evaluated. If its expression evaluates to True, the loop statements are executed. This repetition continues until the Boolean expression evaluates to False.

Example

Assume a flowchart to print users’ friends’ names. The flowchart will prompt the user to enter a friend’s name one at a time. We will display the friend’s name on the console window. The flowchart will exit when the user enters “QUIT” as a friend’s name.

Steps:

Declare a variable to hold the user input.

Assign an initial value to empty string.

Add a while loop to the flow chart. We use while because we don’t know how many names the user will enter during the flowchart runtime.

Add loop statements.

While Loop Example

Sample Output

Execute the flowchart.

While Loop Example Output

 

Indefinite Loop

While loops are indefinite loops that can run forever.  Some applications are designed to run forever until they are interrupted by external signals. A real-world example of this is an application/web server that runs forever to service the client requests. Let’s simulate a loop that runs forever until it’s stopped.

The while loop runs until the conditions become false. If we provide a condition that never evaluates to false the loop runs forever.

Examples, conditions like:

while(1 = = 1)

while( True)

will always evaluate to True boolean truth value.

 

Flowgorithm_Indefinte_While_Loop

 

Sample run output

This flowchart will run forever until it is stopped by an external signal like a user stopping the flowchart or its encounters a runtime error.

 

While Loop Flowgorithm

Note that if the flowchart design doesn’t need an indefinite loop then this could be a defect or error in the flowchart design.

—

Flowgorithm Tutorials Link:

https://www.testingdocs.com/flowgorithm-flowchart-tutorial/

Flowgorithm Website:

http://flowgorithm.org/

Related Posts

Print Triangle Pattern Flowchart

Flowgorithm /

Print Triangle Pattern Flowchart

Flowgorithm Breakpoint Symbol

Flowgorithm /

Flowgorithm Conditional Breakpoint Statement

File Read Declare Variables

Flowgorithm /

Flowgorithm Read Numbers from File Example

File Search Input File Flowgorithm

Flowgorithm /

Search Text File Flowchart Example

Flowgorithm Turtle Graphics Symbols

Flowgorithm /

Flowgorithm Turtle Graphics Symbols

‹ Flowgorithm For Loop Statement› Flowgorithm Do While Loop Statement

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com