Hot answers tagged

2

The error means a path that does not take the if branch or the else branch will not return a boolean, since the returns are embedded in those blocks. Think about this comment //if input name does not match with any name . What the program is doing is //if input name does not match this name . If program returns on the first non-matching name, it will not ...


1

Try an election with 3 candidates, A B C, and 6 voters, with the result A 3, B 1, C 2. The self-evident winner is A with 3 votes. The first print_winner function will return C. On the first iteration of i, winner_votes will be 3. However, on the second iteration, where i equals 1, it will only compare B to C, and winner_votes will be 2. Since the inner (j) ...


1

Have you compiled the program locally? The compiler should complain about this strlen(champions) because champions is declared an int array here int champions[pair_count]


Only top voted, non community-wiki answers of a minimum length are eligible