I tried writing a Pascal Program but whenever i run it in Turbo pascal it does not work. Are there any ways in which I could better improve the code, and what are the possible errors with my code? :( Thanks in advance
Question:
A survey of 10 pop artists is made. Each person votes for an artist by specifying the number of the artist (a value from 1 to 10 ). Write a program to read the names of the artists, followed by the votes, and find out which artist is the most popular. Choose a suitable end-of-data marker.
This is what I have:
Program artistes;
uses crt;
type
artistarray = Array[1..10] of string;
votearray = Array[1..10] of integer;
var
y1, y2, biggest, x: Integer;
artist: artistarray;
vote: votearray;
begin
clrscr;
textcolor(10);
biggest:= 0;
y1:= 0;
y2:= 0;
x:= 0;
write('Enter 10 artists ');
read (artist);
for x := 1 to 10 do
begin
artists[x] := artist;
read(artist);
end;
clrscr;
readln;
readln;
write('enter your vote number : ');
read(vote);
while (vote <> 999) do
begin
vote:= artist[x];
y1 := y + 1;
biggest:= vote;
end;
writeln('Enter your vote number : ');
read(vote);
vote:= artist[x];
y2:= y2 + 1;
If (y2 > y1) then
biggest:= vote
else
Biggest:= biggest;
writeln( 'The most popular artist is: ',vote, '.');
readln;
end.