-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvote_per_cal.cpp
42 lines (35 loc) · 1.01 KB
/
vote_per_cal.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
/*1.Write a cpp program to calculate vote percentage if there are 3 nominess and 10 voters*/
#include<iostream>
using namespace std;
int main(){
cout<<"To enter your vote select one of the candidate"<<endl;
cout<<"1.Utkarsh (BJP)"<<endl;
cout<<"2.Viraj (UPA)"<<endl;
cout<<"3.Sarthak (NCP)"<<endl;
int vote[10];
float vote_utk=0;
float vote_vir=0;
float vote_sar=0;
for(int i=0;i<10;i++)
{
cout<<"Enter Your vote"<<endl;
cin>>vote[i];
if(vote[i]==1) {
vote_utk++;
}
else if(vote[i]==2)
{
vote_vir++;
}
else if(vote[i]==3)
{
vote_sar++;
}
}
float vote_per_utk=(vote_utk/10)*100;
float vote_per_vir=(vote_vir/10)*100;
float vote_per_sar=(vote_sar/10)*100;
cout<<"Vote Percentage of Utkarsh is"<<" "<<vote_per_utk<<endl;
cout<<"Vote Percentage of Viraj is"<<" "<<vote_per_vir<<endl;
cout<<"Vote Percentage of Sarthak is"<<" "<<vote_per_sar<<endl;
}