The FOR ... Next is a most popular and mostly used looping statement which is used to execute the set of statements repeatedly for a given number of times.
Syntax:
FOR = TO STEP n
[statements]
NEXT
Example 1
WAP to print the natural numbers from 1 to 10.
CLS
FOR x = 1 TO 10
PRINT x;
NEXT x
END
Example 2
WAP to print even numbers from 1 to 20
CLS
FOR i = 2 TO 20 STEP 2
PRINT i;
NEXT i
END
Example 3
WAP to print the numbers from 20 to 1 in descending order.
CLS
FOR a = 20 TO 1 STEP -1
PRINT a;
NEXT a
END
Example 4
WAP to print your name 10 times
CLS
FOR i = 1 TO 10
PRINT "Your Name"
NEXT i
END
Example 5
WAP to print the multiplication table of given number.
CLS
INPUT "Enter a number "; n
FOR c = 1 TO 10
PRINT n; "x"; c; "="; n * c
NEXT c
END