The print_winner function must find the candidate who has the highest votes and print its name. In case there are two candidates who have the same number of votes, the function must print 2 names.
Here are the errors
:( print_winner identifies Alice as winner of election
print_winner function did not print winner of election
:( print_winner identifies Bob as winner of election
print_winner function did not print winner of election
:( print_winner identifies Charlie as winner of election
print_winner function did not print winner of election
:( print_winner prints multiple winners in case of tie
print_winner function did not print both winners of election
:( print_winner prints all names when all candidates are tied
print_winner function did not print all three winners of election
Here is my function code
void print_winner(void)
{
int maxx;
maxx = candidates[0].votes;
for (int i = 1; i < candidate_count; i++)
{
if(maxx < candidates[i].votes)
{
maxx = candidates[i].votes;
}
}
for (int j = 0; j < candidate_count; j++)
{
if (candidates[j].votes == maxx)
{
printf("%s \n", candidates[j].name);
}
}
}