How can I manage to let the user input a number (n) and the program will read strings for n times?
I can do that in this way, but not good enough if user enters a number greater than 100.
VAR ar: ARRAY[1..100] OF STRING;
BEGIN
write('Amount: '); readln(n);
FOR i:= 1 TO n DO readln(ar[i]);
I think there would be a better way, maybe using PROCEDURE, but I fail:
VAR n: integer;
PROCEDURE stringsss(j: integer);
VAR ar: ARRAY[1..j] OF STRING;
BEGIN END;
BEGIN {main program}
write('Amount '); readln(n);
stringsss(n)
END.
Actually is there a way of doing that?
Also, if I want to pass strings to the procedure instead of reading from users, is it possible? I mean like:
PROCEDURE stringsss(n: integer; ar: ARRAY[1..n] OF STRING);
BEGIN END;
BEGIN {main program}
stringsss(3, 'john', 'tommy', 'mandy')
END.
The last two are just my concepts, please make some adjustments to suite me needs. Thank you.