Download Introduction to Programming in Turing First Edition
Transcript
Chapter 14 : Arrays and Other Data Types 243 put "Enter the array size : " .. get size var numbers : array 1 .. size of int 14.2 Manipulating Lists Here is a program that reads a list of names and outputs the list in reverse order. % The "ReverseNames" program % Reads a list of names and outputs in reverse var howMany : int put "How many names are there? " .. get howMany var name : array 1 .. howMany of string (20) put "Enter ", howMany, " names, one to a line" for i : 1 .. howMany get name (i ) : * end for put "Here are the names in reverse order" for decreasing i : howMany .. 1 put name (i ) end for Notice that the variable name is an array of strings of maximum length 20. This saves space since the default length of strings is 256. The number of elements in the array is not known until the program executes. At that time you tell it how many there are. This is known as dynamic declaration of an array. Here is an Execution window. How many names are there? 4 Enter 4 names, one to a line Mark Mendell Steve Perelgut Chris Stephenson
Related documents
R300 User guide
Sony Ericsson R306 User Guide
Tannoy T303 Cell Phone User Manual
Sony Spiro W100i 90g Black
Deutsche Telekom Sony Ericsson Spiro W100i, TMO XTRA 2.2" 90g Green, White
DFI CM64-AL User`s manual
English - Insignia
Check-In User Manual Ver 3
A711 PRINTER SERIES REFERENCES NSKGG**** USER MANUAL
Check-In Station User Manual
TRITON 60 SERIES 60 mm MINI-KIOSK USER MANUAL
SDS Landval User Manual V710