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.

  • Try taking the space out of the output here 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. Jan 15, 2020 at 12:26
  • Thanks, no errors now! i will keep this in mind
    – rassenguy
    Jan 15, 2020 at 14:19

2 Answers 2


All you have to do is add \n after %s. (No space in between). Thank @rassenguy

  • I change my code a thousand times till I found out this was it..... sigh
    – mz1user
    Dec 1, 2021 at 13:51
  • Thanks, thats all about it
    – Arizona
    Jan 28 at 8:57
int majority = round((float) voter_count / 2);

Make sure that majority is calculated correctly. Right now you're only computing half of the voters.

Also, why are you casting to float ?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .