-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEx 1B..Switch case,Do-While.cpp
45 lines (45 loc) · 1.47 KB
/
Ex 1B..Switch case,Do-While.cpp
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
#include<iostream>
using namespace std;
int main()
{
int i,can[5],ballot,count[5];
char ch;
for(i=0;i<=5;i++)
{
count[i]=0;
}
do
{
cout<<"\nEnter the ballot number :";
cin>>ballot;
switch(ballot)
{
case 1:
count[1]++;
break;
case 2:
count[2]++;
break;
case 3:
count[3]++;
break;
case 4:
count[4]++;
break;
case 5:
count[5]++;
break;
default:
count[0]++;
}
cout<<" \nWant to vote again\n";
cin>> ch;
}
while(ch=='y');
for(i=1;i<=5;i++)
{
cout<<"\nNo:of votes for candidate "<< i <<"="<<count[i];
}
cout<<"\n Sploit ballots are "<<count[0];
return 0;
}