-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path3.c
More file actions
47 lines (39 loc) · 904 Bytes
/
Copy path3.c
File metadata and controls
47 lines (39 loc) · 904 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#define BALLOTS 100
int main()
{
int i, b_number;
int votes[6] = {0}; // Increased the size of the 'votes' array to 6
printf("Enter Ballot's Number Per Candidates:\n");
for (i = 0; i < BALLOTS; i++)
{
scanf("%d", &b_number);
switch (b_number)
{
case 1:
votes[1]++;
break;
case 2:
votes[2]++;
break;
case 3:
votes[3]++;
break;
case 4:
votes[4]++;
break;
case 5:
votes[5]++;
break;
default:
votes[0]++;
break;
}
}
for (i = 1; i <= 5; i++)
{
printf("Candidate %d Got %d Votes\n", i, votes[i]);
}
printf("There are %d Spoilt Votes\n", votes[0]);
return 0;
}