This is it — your capstone! Bring together variables, loops, conditionals, and functions to build a program that collects votes and announces the winner.
YOUR TASK
Write a C program that:
Has 3 candidates: Alice, Bob, and Carol
Asks how many voters will vote (you decide the number in the input)
Loops that many times, accepting a vote of 1, 2, or 3
Counts each candidate's votes
Prints the winner by name at the end
Uses at least one helper function (e.g. to find the winner)
Need a hint?
Suggested structure:
1. Declare int alice=0, bob=0, carol=0;
2. Read int voters; then loop for(int i=0; i<voters; i++)
3. Inside the loop, read a vote and increment the right counter
4. Write a getWinner(int a, int b, int c) function that returns 1, 2, or 3
5. Call it and print the matching name
For the test: input will be 3\n2\n1\n2 meaning 3 voters voting Bob, Alice, Bob → Bob wins
Example (3 voters: 2, 1, 2 → Bob wins):
1. Alice
2. Bob
3. Carol
Voters: 3
Vote: 2
Vote: 1
Vote: 2
Winner: Bob
Code Editor
Ready
Output
Console
Console initialized...
Ready for the Final Project: Mini Voting System
> This is your capstone — bring everything together!
> Use "Check My Code" to validate, then complete the course!