Question: b) An election is contested by five candidates. The candidates are numbered 1 to 5 and the voting is done by marking the candidate number

 b) An election is contested by five candidates. The candidates are

b) An election is contested by five candidates. The candidates are numbered 1 to 5 and the voting is done by marking the candidate number on the ballot paper. Build a C++ program to read the ballots and count the vote cast for each candidate using an array variable count. In case, a number read is outside the range 1 to 5, the ballot should be considered as a "spoilt ballot" and the program should also count the numbers of spoilt ballots". The output of the program may look like this: You can vot candidate 1 to 5 press 1 or 2 or 3 or 4 or 5 to vote. Press enter each time the vote is made. candidate 1 or 2 or 3 or 4 or 5 respectively press any integer value outside the range 1 to 5 for NO VOTE press any negative value to terminate and see result: 1 1 1 5 1 3 candidate 1 candidate 2 candidate 3 candidate 4 candidates 41213 spoilt_ballot 1 [20 Marks)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!