3 Replies - 1393 Views - Last Post: 14 March 2013 - 04:12 AM Rate Topic: -----

#1 bossunkun  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-March 13

Writing a program to find the highest of a list of numbers

Posted 13 March 2013 - 05:41 PM

Hi guys! I'm sure this is the wrong place since it's Pascal but I need immediate help.
I'm supposed to write this program while will accept an unknown number of names of candidates and the total votes that person has recieved. It's a program to do with elections. It basically has to find the Highest number among the numbers inputted and print "The winner is .....!"
I'm not sure I've written my program the correct way, but I keep getting this error. I would appreciate it if anyone could after this for me please.

Posted Image

This is the error:
Posted Image

View Postbossunkun, on 13 March 2013 - 05:39 PM, said:

Posted Image

This is the error:
Posted Image


Sorry about that. I didn't see any edit button.

Is This A Good Question/Topic? 0
  • +

Replies To: Writing a program to find the highest of a list of numbers

#2 Skydiver  Icon User is offline

  • Code herder
  • member icon

Reputation: 3475
  • View blog
  • Posts: 10,721
  • Joined: 05-May 12

Re: Writing a program to find the highest of a list of numbers

Posted 13 March 2013 - 06:34 PM

1. That code is Pascal. This is a C / C++ forum.
2. Paste in your code, not screenshots.

Moving to a more appropriate forum...
Was This Post Helpful? 0
  • +
  • -

#3 bossunkun  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 13-March 13

Re: Writing a program to find the highest of a list of numbers

Posted 14 March 2013 - 12:38 AM

program election;

var name:string;
    votes:integer;


Highest:=0;
Begin
   writeln('Enter the candidate name.');
   readln(name);
   writeln('Enter the votes the candidate has recieved.');
   readln(votes);
   WHILE votes<>0 DO
           IF votes>Highest THEN
                    Highest:=votes;
           end
           writeln('Enter the candidate name.');
           readln(name);
           writeln('Enter the votes the candidate has recieved.');
           readln(votes);
   end
   writeln('The winner is',name);
End.

Was This Post Helpful? 0
  • +
  • -

#4 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2089
  • View blog
  • Posts: 3,181
  • Joined: 21-June 11

Re: Writing a program to find the highest of a list of numbers

Posted 14 March 2013 - 04:12 AM

It's expecting Highest to be followed by a colon and type name, not by the assignment operator. You should have Highest : integer; in the var section and then Highest := 0; after the Begin.

This post has been edited by sepp2k: 14 March 2013 - 04:13 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1