the program im trying to make will select a random movie from a list of movies and tell the user which 1 he should watch.

first the program will ask how many movies there are. it will then ask for the titles of each movie and then it will output a random movie.

this is what i have so far:

program Movie_Randomizinationer;
uses crt;

var
m:array[1..10] of string;
hm:integer;
c:integer;
ran:string;

begin
clrscr;

write('How many movies are there?  ');
readln(hm);

c:=0;

repeat
clrscr;
c:=c+1;
writeln('Enter in title for movie ',c,':');
readln(m[c]);
until c=hm;

clrscr;
randomize;
ran:=m(random[1..hm]);       {this is wrong and i dont know how to continue from here on}

writeln('You will be watching ');
writeln(ran);
readln;
end.

can anyone help please?

nevermind. i managed after trying out some other stuff :P

heres the code if anyone cares:

program Movie_Randomizinationer;
uses crt;

var
m:array[0..10] of string;
hm:integer;
c:integer;
diff:integer;

begin
clrscr;

write('How many movies are there?  ');
readln(hm);

c:=0;
diff:=0;

repeat
clrscr;
diff:=diff+1;
writeln('Enter in title for movie ',diff,':');
readln(m[c]);
c:=c+1;
until c=hm;

clrscr;
randomize;

writeln('You will be watching ');
writeln(m[random(hm)]);
readln;
end.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.