VOTING SYSTEM IN C LANGUAGE
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
#include<conio.h>
int show(int);
void Admin(int,int,int);
int main()
{
int p,n,n1,i,pin,reg,k=0,party,id[100],a;
int party1=0;
int party2=0;
int party3=0;
char ch;
cout<<("\n1).Admin");
cout<<("\n2).Voter");
cout<<("\n3).exit");
cout<<("\n\t\t\t\tInput the Choice : ");
p=show(n);
if(p==1)
{
Admin(party1,party2,party3);
}
else if(p==2)
{
while(1)
{
cout<<("Enter registration no. : ");
cin>>reg;
system("cls");
int found=0;
for(i=0;i<=k;i++)
{
if(reg==id[i])
found=1;
}
if(found==0)
{
id[k++]=reg;
cout<<("\t\t\t\tChoose the party");
cout<<("\n1).BJP");
cout<<("\n2).Congress");
cout<<("\n3).Aam Aadmi\n");
scanf("%d",&party);
system("cls");
if(party==1)
party1++;
else if(party==2)
party2++;
else if(party==3)
party3++;
else
break;
}
cout<<("Enter 1 to continue and 0 to break");
cin>>n1;
system("cls");
if(n1==1)
continue;
else
{
cout<<("Enter your choice : ");
p=show(n);
if(p==1)
Admin(party1,party2,party3);
}
}
}
else
cout<<("Please Exit the area");
}
void Admin(int party1,int party2,int party3)
{
char ch;
int a=0,i;
int pin;
pin=1234;
printf("Enter your four digit pin : ");
for(i=1;i<=4;i++)
{
ch=getch();
printf("*");
ch=ch-48;
a=(a*10)+ch;
}
if(party1==party2&&party2==party3)
{
cout<<("\nThere will be re-election");
}
else if(party1!=party2||party2!=party3||party3!=party1)
{
if(a==pin)
{
if(party1>party2)
{
if(party1>party3)
cout<<("\nThe winner is BJP\n");
else
cout<<("\nThe winner is AAM AADMI Party\n");
}
else if(party2>party3)
cout<<("\nThe winner is congress\n");
else
cout<<("\nThe winner is AAM AAdMI Party\n");
}
}
else
cout<<("\nThe pin is Wrong");
}
int show(int n)
{
cin>>n;
return(n);
system("cls");
}
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
using namespace std;
#include<conio.h>
int show(int);
void Admin(int,int,int);
int main()
{
int p,n,n1,i,pin,reg,k=0,party,id[100],a;
int party1=0;
int party2=0;
int party3=0;
char ch;
cout<<("\n1).Admin");
cout<<("\n2).Voter");
cout<<("\n3).exit");
cout<<("\n\t\t\t\tInput the Choice : ");
p=show(n);
if(p==1)
{
Admin(party1,party2,party3);
}
else if(p==2)
{
while(1)
{
cout<<("Enter registration no. : ");
cin>>reg;
system("cls");
int found=0;
for(i=0;i<=k;i++)
{
if(reg==id[i])
found=1;
}
if(found==0)
{
id[k++]=reg;
cout<<("\t\t\t\tChoose the party");
cout<<("\n1).BJP");
cout<<("\n2).Congress");
cout<<("\n3).Aam Aadmi\n");
scanf("%d",&party);
system("cls");
if(party==1)
party1++;
else if(party==2)
party2++;
else if(party==3)
party3++;
else
break;
}
cout<<("Enter 1 to continue and 0 to break");
cin>>n1;
system("cls");
if(n1==1)
continue;
else
{
cout<<("Enter your choice : ");
p=show(n);
if(p==1)
Admin(party1,party2,party3);
}
}
}
else
cout<<("Please Exit the area");
}
void Admin(int party1,int party2,int party3)
{
char ch;
int a=0,i;
int pin;
pin=1234;
printf("Enter your four digit pin : ");
for(i=1;i<=4;i++)
{
ch=getch();
printf("*");
ch=ch-48;
a=(a*10)+ch;
}
if(party1==party2&&party2==party3)
{
cout<<("\nThere will be re-election");
}
else if(party1!=party2||party2!=party3||party3!=party1)
{
if(a==pin)
{
if(party1>party2)
{
if(party1>party3)
cout<<("\nThe winner is BJP\n");
else
cout<<("\nThe winner is AAM AADMI Party\n");
}
else if(party2>party3)
cout<<("\nThe winner is congress\n");
else
cout<<("\nThe winner is AAM AAdMI Party\n");
}
}
else
cout<<("\nThe pin is Wrong");
}
int show(int n)
{
cin>>n;
return(n);
system("cls");
}