Repetition Statement

From SwinBrain

A Repetition statement allows the program to perform a set of instructions multiple times.

The image shown here is a flow chart that illustrates a repetition statement.

This flowchart shows a repetition statement

The program reads the users name from the console and then initialises the Count variable. A set of statements are then repeated while the expression Count < 10 is true. These statements include writing 'silly ' to the console, and increasing Count by 1. When this repetition finishes the program writes 'name' to the console and then ends. The pascal program to implement this flow chart is shown below.

program SillySillyName;
{ This program displays a message for the
  users of the program. }
  Name : String;   //The name of the user running the program
  Count : Integer; //This is used to control the repetitions
  Write('Please enter your name: ');
  Count := 0;
  Write('That is a ');
  while( Count < 10 ) DO
      Write('silly ');
      Count := Count + 1;

Also See

Selection Statement

[edit]Links: Topic Brains
Return to Swin Brain