Do...Loop...While

 Do...Loop...While:

This loop executes one or more statements while the given condition is true. this loop is similar to the Do...While...Loop but the difference of Do...While...loop and Do...loop...is that it first execute the statement and then check the condition. By this loop statement execute once even the condition is false.So this loop should  be used when we want to execute the statement at least once.

Syntax:

The syntax of this loop is as follows:
Do
    Statement(s)
    Statement(s) 
Loop While condition

Flow Chart:

The flow chart of  D...Loop...While is as follows:

Example:

Write a program that gets a number from user and display the table of that number.
  • Start a new standard EXE project.
  • Design the form as follows.



























  • double click the click event of  input button and write following code.



  • Run the project click on the button.
  • Your program take input from you.
  • Output is display as.

How It Works?

The above Example is executed for ten times each times the value of counter variable is changed.
So that the output statement will be displays different result on the form.

No comments:

Post a Comment