Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

VOTING SYSTEM

INTRODUCTION:
The basic structure of a voting system consists of a user interface,
a database to store information about candidates and voters, and
a set of rules to ensure fair and accurate voting. The user interface
allows voters to select their preferred candidate or option and
submit their vote. The database stores information about the
candidates, such as their names, photos, and party affiliations, as
well as information about the voters, such as their names and
voting histories. The set of rules ensures that each voter can only
vote once and that the votes are counted accurately.

ALGORITHM:
1. Define a struct to represent a candidate with the following
fields.
2. Define an array of candidate structs to store the candidates
in the election.
3. Initialize the candidate’s array with the names of the
candidates and set their initial vote count to zero.
4. Prompt the user to cast a vote for a candidate by entering
their name.
5. Read in the users vote and compare it to the names of the
candidates in the candidates’ array.
6. If the users vote matches a candidate’s name, increment that
candidate’s vote count.
7. Repeat steps 4-6 until the user indicates that they have
finished voting.
8. Afterall votes have been cast, loop through the candidate’s
array to find the candidate with the highest number of votes.
9. Print the names of the candidates with the highest number
of votes and number of votes they received.

FLOW CHART:

Start

Initialize variables
(Age, choice,)

candidateA, candidateB

total Voters, voteAgain

Do-while loop

(voteAgain == 'y' || 'Y’)

Enter age

Check eligibility
(age >= 18)

Enter choice

Cast vote for candidate


Ask to vote again

Loop if voteAgain = 'y'

Display results

Total Voters, candidateA,


candidateB, election winner
End

You might also like