-
Notifications
You must be signed in to change notification settings - Fork 97
/
votingsystem.c
82 lines (69 loc) · 1.59 KB
/
votingsystem.c
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include <stdio.h>
int main()
{
//variables
int choose;
int i=1,bjp=0,con=0,aap=0,sjp=0,a;
// are declared here.
printf("*************WELCOME TO SIMPLE VOTING SYSTEM**************** \n");
printf("\t -------MLA ELECTIONS-------\n");
printf("Press 1 to cast vote\n");
scanf("%d",&a);
if(a==1){
while(i>0)
{
printf("*************************Choose One to Vote*****************************\n");
printf (" 1.BJP | 2.Congress \n");
printf(" 3.AAP | 4.Samajvadi Party ");
printf("\n******************************************************\n");
printf("\n*********************5.View Results***********************************\n");
scanf("%d",&choose);
//loop 1
if(choose==1)
{
bjp+=1;}
else if(choose==2)
{con+=1;}
else if(choose==3)
{aap+=1;}
else if(choose==4)
{sjp+=1;}
else if(choose==5)
{
break;
}
else
printf("Enter Appropriate Number");
}
printf("BJP= %d\n",bjp);
printf("Congress= %d\n",con);
printf("AAP= %d\n",aap);
printf("Samajvadi Party= %d\n",sjp);
i++;
}
//loop1 ends
else if(a==2)
{
printf(" BJP= %d\n",bjp);
printf("Congress= %d\n",con);
printf("AAP= %d\n",aap);
printf("Samajvadi Party= %d\n",sjp);
}
if(bjp>con && bjp>aap && bjp>sjp)
{
printf("The Winner is BJP");
}
else if(con>bjp && con>aap && con>sjp)
{
printf("The Winner is Congress");
}
else if(aap>bjp && aap>con && aap>sjp)
{
printf("The Winner is AAM AADMI PARTY ");
}
else if (sjp>bjp && sjp>con && sjp>aap)
{
printf("The Winner is SAMAJWADI PARTY");
}
return 0;
}