0

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.
  • You should be more specific, especially about "it does not work". – Drunix Mar 23 '14 at 19:27
  • To start with, you are reading 11 artists and storing the first ten. – Millie Smith Mar 23 '14 at 19:29
  • Also, you always decide that the last person voted for is the most popular... you aren't even using your "biggest" variable (which isn't set right in the first place). And you don't read in votes in a loop so you only read two votes... is that what you wanted? – Millie Smith Mar 23 '14 at 19:33

0 Answers0