I keep getting these errors when running check50 on my runoff program:
print_winner prints name when someone has a majority print_winner did not print winner of election
print_winner returns true when someone has a majority print_winner did not print winner and then return true
I don't understand what the problem is since when I run my own tests it seems that my program does print out a candidate with the majority of votes! Does anyone know the metrics that check50 is using for print winner I would like to test that out myself? otherwise, this is my code:
// Print the winner of the election, if there is one
bool print_winner(void)
{
int majority = round((float) voter_count / 2);
bool winner = false;
for (int i = 0; i < candidate_count; i++)
{
// if any candidate has more then half of the votes (majority) print out their name and return true
if (candidates[i].votes > majority)
{
printf("%s \n", candidates[i].name);
winner = true;
}
}
return winner;
All of the other program requirements are good.
printf("%s \n", candidates[i].name);
. I know that it's not specified in the spec (which it commonly is), but historically speaking, check50 is looking for an "exact match" of some kind.