Here, Today we gonna make a simple graphic-based project Electronic Voting Machine Prototype using C, which demonstrates the working of the electronic voting machine. This project shows the working principle, vote counting, and percentage calculation with the color full image.
If you wish to make innovative projects either for your knowledge or for college projects, then this project is best for you.
This project is tested on TurboC++ on Windows OS. We recommended you use TurboC++ (on window os) to run this project.
Check out other interesting projects using C posted in bestengineeringprojects.com
- LASER Demonstration Program using C
- Simple RADAR Program using C
- College Information System using C
- Elementary Database management using C
Source Code
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
#include<stdio.h> // HEADER FILE FOR STANDARD I/0 #include<graphics.h> // HEADER FILE FOR GRAPHICS MODE #include<dos.h> // HEADER FILE FOR ENABLING SOUND #include<conio.h> // HEADER FILE FOR CONSOLE I/O #include<stdlib.h> // HEADER FILE FOR LIBRARY FUNCTIONS union REGS i,o; int initmouse(); // FUNCTION TO INITIALIZE MOUSE POINTER void showmouseptr(); // FUNCTION TO SHOW POINTER void restrictmouseptr(int,int,int,int); // FUNCTION TO RESTRICT POINTER void getmousepos(int *,int *,int *); // TO GET POINTER POSITION void format(); // FUNCTION TO DRAW LAYOUT OF EVM void graph(); // FUNCTION TO DISPLAY RESULT AS GRAPH void welcome(); // FUNCTION TO DISPLAY WELCOME MESSAGE void boundry(); int vote1=0,vote2=0,vote3=0,vote4=0,vote5=0; // VARIABLES TO HOLD VOTES FOR CANDIDATES int button,x,y; void main() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\turboc3\\bgi"); // INITIALIZING GRAPHICS MODE randomize(); boundry(); welcome(); // CALLING WELCOME FUNCTION cleardevice(); // CLEARING THE SCREEN format(); // CALLING FORMAT FUNCTION showmouseptr(); restrictmouseptr(0,0,675,435); // RESTRICTING MOUSE POINTER WITHIN SCREEN do { getmousepos(&button,&x,&y); if((button&1)==1&&x>475&&x<580&&y>250&&y<280) { break;} else if((button&1)==1&&x>280&&x<380&&y>105&&y<125) { setcolor(RED);circle(270,115,5); sound(1200); delay(500); nosound(); setcolor(BLACK);circle(270,115,5); vote1++; } else if((button&1)==1&&x>280&&x<380&&y>155&&y<175) { setcolor(RED);circle(270,165,5); sound(1200); delay(500); nosound(); setcolor(BLACK);circle(270,165,5); vote2++; } else if((button&1)==1&&x>280&&x<380&&y>205&&y<225) { setcolor(RED);circle(270,215,5); sound(1200); delay(500); nosound(); setcolor(BLACK);circle(270,215,5); vote3++; } else if((button&1)==1&&x>280&&x<380&&y>255&&y<275) { setcolor(RED);circle(270,265,5); sound(1200); delay(500); nosound(); setcolor(BLACK);circle(270,265,5); vote4++; } else if((button&1)==1&&x>280&&x<380&&y>305&&y<325) { setcolor(RED);circle(270,315,5); sound(1200); delay(500); nosound(); setcolor(BLACK);circle(270,315,5); vote5++; } } // END OF DO while(1); cleardevice(); initmouse(); showmouseptr(); boundry(); graph(); getch(); } // END OF MAIN FUNCTION void boundry() { setcolor(1+random(14)); rectangle(0,0,635,475); setcolor(1+random(14)); rectangle(3,3,632,472); } void welcome() { randomize(); settextstyle(8,0,4); setcolor(1+random(14)); outtextxy(200,100,"WELCOME"); delay(800); setcolor(1+random(14)); outtextxy(250,160,"TO"); delay(800); setcolor(1+random(14)); outtextxy(50,220,"ELECTRONIC VOTING SYSTEM"); delay(800); while(!kbhit()) { setcolor(1+random(14)); outtextxy(50,400,"Press any key to continue....."); delay(500); setcolor(BLACK); outtextxy(50,400,"Press any key to continue....."); delay(500); } } void format() { setcolor(6); rectangle( 90,30,400,380); rectangle( 87,27,403,383); settextstyle(0,0,5); outtextxy(140,40,"E V M"); line(90,80,400,80); settextstyle(8,0,2); outtextxy(100,100,"Krishna"); rectangle(95,100,250,130); arc(290,115,90,270,10); arc(370,115,270,90,10); line(290,105,370,105); line(290,125,370,125); outtextxy(100,150,"Shekhar"); rectangle(95,150,250,180); arc(290,165,90,270,10); arc(370,165,270,90,10); line(290,155,370,155); line(290,175,370,175); outtextxy(100,200,"Parmila"); rectangle(95,200,250,230); arc(290,215,90,270,10); arc(370,215,270,90,10); line(290,205,370,205); line(290,225,370,225); outtextxy(100,250,"Hackentio"); rectangle(95,250,250,280); arc(290,265,90,270,10); arc(370,265,270,90,10); line(290,255,370,255); line(290,275,370,275); outtextxy(100,300,"Subash"); rectangle(95,300,250,330); arc(290,315,90,270,10); arc(370,315,270,90,10); line(290,305,370,305); line(290,325,370,325); rectangle(475,250,580,280); outtextxy(480,250,"RESULTS"); outtextxy(50,400,"Presented By:- Best Engineering Projects"); } void showmouseptr() { i.x.ax=1; int86(0x33,&i,&o); } void restrictmouseptr(int x1, int y1, int x2, int y2) { i.x.ax=7; i.x.cx=x1; i.x.dx=x2; int86(0x33,&i,&o); i.x.ax=8; i.x.cx=y1; i.x.dx=y2; int86(0x33,&i,&o); } void getmousepos(int *button, int *x, int *y) { i.x.ax=3; int86(0x33,&i,&o); *button=o.x.bx; *x=o.x.cx; *y=o.x.dx; } void graph() { outtextxy(200,100,"RESULTS(in % votes)"); int candidate1=((vote1*100)/(vote1+vote2+vote3+vote4+vote5)); int candidate2=((vote2*100)/(vote1+vote2+vote3+vote4+vote5)); int candidate3=((vote3*100)/(vote1+vote2+vote3+vote4+vote5)); int candidate4=((vote4*100)/(vote1+vote2+vote3+vote4+vote5)); int candidate5=((vote5*100)/(vote1+vote2+vote3+vote4+vote5)); setcolor(2); rectangle(100,300,130,300-candidate1);outtextxy(100,300,"Krish"); rectangle(200,300,230,300-candidate2);outtextxy(200,300,"Shekh"); rectangle(300,300,330,300-candidate3);outtextxy(300,300,"Prami"); rectangle(400,300,430,300-candidate4);outtextxy(400,300,"Hacke"); rectangle(500,300,530,300-candidate5);outtextxy(500,300,"Subas"); setcolor(1+random(14)); rectangle(545,400,600,430); outtextxy(550,400,"EXIT"); do { getmousepos(&button,&x,&y); if((button&1)==1&&x>545&&x<600&&y>400&&y<430) { break;} } // END OF DO while(1); } initmouse() { i.x.ax=0; int86(0x33,&i,&o); return(o.x.ax); } |
The output of Electronic Voting Machine Prototype Using C
Figure 1: Electronic Voting Machine Output Screen 1
Figure 2: Electronic Voting Machine Output Screen 2
Figure 3: Electronic Voting Machine Output Screen 3
Figure 4: Electronic Voting Machine Output Screen 4
hey how can we take multiple user inputs in this?
My clicking the respective box.