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 Nested For Loops

Overview

In this tutorial, we will learn about Nested for loops in Flowgorithm flowcharts. A for loop placed inside another for loop is called a nested for loop. In general, the outside loop is called the outer for loop. The loop placed inside is called the inner for loop.

Number of Iterations

If the outer loop iterates for M iterations and the inner loop iterates for N iterations, the total number of iterations the whole nested for loop construct iterates is

Total = M * N iterations.

Example

In this example, we will draw a square pattern with the asterisk(*) character using nested for loops in the flowchart.

The general steps to design the flowchart are as follows:

Launch Flowgorithm flowchart tool.

Declare variables N, and loop counter variables like i and j. The i variable is to control the outer for loop. The j variable is to control the inner for loop.

Prompt user to enter the variable N. The number of rows in the pattern.

Add two for loop statements

The outer loop runs N times to print N rows. The Inner for loop run to print N asterisk characters.

Nested For Loops Flowgorithm

In the inner for loop print the asterisk character to the console and remove the New line option.

In the outer for loop add a blank Output symbol and check the New Line check box. This will carriage return and go to the next line for the next for loop iteration.

Sample Output

Nested Loop Flowchart Output Flowgorithm

That’s it. We have successfully designed a flowchart to print the square pattern with * character.

Exercises

#1

Triangle Pattern

Now that you have learned to print the square pattern. Modify or create a new flowchart to print a triangle pattern.

The Nth row of the pattern should print N * characters.

Exercise Nested For Loop Flowgorithm

#2

Print Triangle Pattern to a File

Flowgorithm 3.0 version supports File I/O symbols. Print the triangle pattern with * character to an output file, for example to an output.txt text file.

—

Flowgorithm Tutorials

Flowgorithm flowchart tutorials on this website:

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

Flowgorithm Website

For more information on the Flowgorithm tool, please visit the official website at:   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 Nested If Statements› Flowgorithm Expressions

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