Empowering CS learners, aspiring programmers, and startups with AI, Data Science & Programming insights — scaling skills from learning foundations to enterprise-grade solutions.
// Update ranks given a new vote
bool vote(int rank, string name, int ranks[])
{
// TODO
for (int i = 0; i < candidate_count; i++)
{
if (strcmp(name, candidates[i]) == 0)
{
//NEED TO INCREMENT VOTES RECEIVED BY CANDIDATES[I] BY 1 FOR RANKS[J]
preferences[i][rank] = preferences[i][rank] + 1;
printf("rank is %i", preferences[i][rank]);
return true;
}
}
return false;
}
[/dm_code_snippet] Not sure if I am moving in the right direction. By the above vote function, no. of votes for a particular rank getting incremented by 1. Is that the objective of the vote function?