CS1001 - D Term, 2000
Laboratory 3 - Loops
Date: April 5, 2000
Given below is a WHILE loop that executes n times, where n is input by the user:
read *, n
lcv = 1
DO WHILE (lcv
.le. n)
{body of loop goes here}
lcv = lcv + 1
END DO
On a separate piece of paper, write your name, wpi login
name, section number, and a DO loop
that is equivalent to the WHILE loop given above.
Write a program which asks the user to enter an integer
n. Then use either a WHILE loop or a
DO loop to print the first n numbers in the series of
integers whose successive differences is the
set of counting integers. An example output is:
How many numbers in the series do you want displayed?
9
Here is the series
1
2
4
7
11
16
22
29
37
Hint: If you get stuck, you can try approaching it this
way: initialize your loop control variable to
zero, and use the loop control variable as the difference
between the last number printed and the
next number to print.
Compile your program.
Use the 'script' command to record your program's execution.
Turn in your program and typescript file electronically
by typing in the command
/cs/bin/turnin submit cs1001 lab3 lab3.f90 lab3.script
This document was generated using the LaTeX2HTML translator Version
97.1 (release) (July 13th,
1997)
Copyright © 1993, 1994, 1995, 1996, 1997, Nikos Drakos, Computer
Based Learning Unit,
University of Leeds.
The command line arguments were:
latex2html lab3.tex.
The translation was initiated by Nitin John on 4/3/2000