Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
13 views1 page

Pascal Programme Code55

The document contains a Pascal program that determines the winner of an election based on votes received by candidates. It defines a function 'find_winner' that iterates through the candidates and their corresponding votes to identify the candidate with the highest votes. In this example, candidates Alice, Bob, Charlie, and Diana have received varying votes, with the program outputting the winning candidate.

Uploaded by

Clavia Thomas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Pascal Programme Code55

The document contains a Pascal program that determines the winner of an election based on votes received by candidates. It defines a function 'find_winner' that iterates through the candidates and their corresponding votes to identify the candidate with the highest votes. In this example, candidates Alice, Bob, Charlie, and Diana have received varying votes, with the program outputting the winning candidate.

Uploaded by

Clavia Thomas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

program ElectionWinner;

uses crt;

function find_winner(candidates: array of string; votes: array of integer): string;


var
max_votes, i: integer;
winner: string;
begin
max_votes := -1;
winner := '';

for i := 0 to High(candidates) do
begin
if votes[i] > max_votes then
begin
max_votes := votes[i];
winner := candidates[i];
end;
end;

find_winner := winner;
end;

var
candidates: array[0..3] of string = ('Alice', 'Bob', 'Charlie', 'Diana');
votes: array[0..3] of integer = (1500, 2300, 2300, 2000);
winner: string;

begin
winner := find_winner(candidates, votes);
writeln('The winning candidate is: ', winner);
readln;
end. V

You might also like