DO is a keyword of so many programming languages that it's pointless to list them all here. DO got its start with the original high level language, FORTRAN. A typical DO statement would look like:
10     DO 60 I=1,10
20     WRITE (2, 30) I
30     FORMAT ('HELLO, MOM #', I2)
40     WRITE (2, 30) I*10
50     FORMAT ('PLEASE SEND ', I3, 'DOLLARS')
60     CONTINUE

The DO statement is on line 10. The first token following the keyword DO is a line number, pointing to the last statement to loop through. We'll get back to this.

Following the terminating line number is the name of a variable, and two numbers separated by commas. The variable would get assigned the first number, and the program would execute down through the program until it executed the statement at the terminating line number. Then control would pass back up to the DO statement where the variable would be incremented by 1. If this value equaled the second number, control would jump down to the first statement after the terminating line number. If you didn't your do loop's numbers correctly, you could get an infinite loop.

By convention, the statement at a DO loop's terminating line number was a CONTINUE statement. Since this isn't strictly necessary, and since the FORMAT statements don't need to be inside the loop, the DO statement above could just as easily have read DO 40 I=1,10! However, the convention was so strong that FORTRAN IV compilers issued a warning if the statement referenced by a DO loop wasn't a CONTINUE. (One of my high school FORTRAN IV programs was marked down because I didn't DO this!)

DO was included in FORTRAN as it was a means of looping that could be optimized. Many later languages adopted the word DO into their syntax, even though it was not strictly necessary. I assume this was an attempt to seduce FORTRAN programmers into trying the language by giving them something familiar.


Pascal uses DO in a rather peculiar fashion. DO acts a sort of sentinel in several of its control statements, stating that the control part is done and the statements being controlled are about to begin. Thus,

for i := 1 to 10 do statement;
while condition do statement;
with structure do statement;