r/delphi • u/[deleted] • Nov 08 '21
A for loop question
Hi i just wanna ask if a for loop runs 7 times to get 7 random numbers. How do i get each random number apart from the loop to process? PLS help me
3
u/bleuge Nov 09 '21
var
c1:integer;
myarray:array[1..7] of integer;
//arrays are just as a variable, but they store more than 1 value,
//accessing value n is just using array[n]
begin
for c1:=1 to 7 do
myarray[c1]:=random(1000); //get random from 0 to 999
//now we are out of the loop, retrieve and print the values
for c1:1 to 7 do
writeln(myarray[c1]);
//easy ;)
end.
1
1
Nov 08 '21
Sorry for this i have to figure out all my work by my self and mot sure how all the functions work
2
1
3
u/JimMcKeeth Delphi := ∞; Nov 08 '21
Store the numbers in an array