0

Hey I don't really know how to ask my question, I will try to summarize. In candidates[i].votes I want to add a if to printf a specific things if I get two candidates the same results. In the base thing that only printf two times the same things with a different name for the candidate. But the problem is I don't know how to specify it and say a new line to specify an another winner.

void print_winner(void)

{ int maxvotes = 0;

for (int i = 0; i < candidate_count; i++)
{
    if (candidates[i].votes > maxvotes)
    {
        maxvotes = candidates[i].votes;
    }
}

for (int i = 0; i < candidate_count; i++)
{
    if (candidates[i].votes == maxvotes)
    {
        printf("%s win with %d votes\n", candidates[i].name, candidates[i].votes);
    }
}
return;

}

0

You must log in to answer this question.

Browse other questions tagged .