0

Here is my Tabulate Function -

void tabulate(void)
{
    int j = 0;
    for (int i = 0; i < voter_count; i++)
    {
        if (candidates[preferences[i][j]].eliminated == 1)
        {
            j++;
        }
        for (int k = 0; k < candidate_count; k++)
        {
        if (strcmp(candidates[preferences[i][j]].name, candidates[k].name) == 0)
        {
            candidates[k].votes++;
        }
        }
    }
}

I know this isn't working as the increment part of j is not in a loop but i tried looping that and broke more stuff than I fixed. Can someone please help me with this.

1

You should try resetting j to 0 every time the outer loop restarts. And you should also check if any other candidates are also eliminated to make sure that the right candidate's votes are incremented.

If this helps, please check the tickmark.

You must log in to answer this question.

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