C++ program Input list of candidates and find winner of the Election based on received votes
belongs to collection: C++ Classes and Object programs
All Answers
total answers (1)
belongs to collection: C++ Classes and Object programs
total answers (1)
Construction of object for the problem...
For this very problem, we need to create a new object, candidate, which has members:
Thus define a class like following:
Thus now a new type of object variable we will create that is candidate & the algorithm is based on the class definition.
Algorithm:
For i=0:4 total_vote+= array[i].vote End for loop
C++ implementation
Output (first run):
Output (second run):
need an explanation for this answer? contact us directly to get an explanation for this answer