0% found this document useful (0 votes)
189 views20 pages

DSA Project

Uploaded by

inamkesoham5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
189 views20 pages

DSA Project

Uploaded by

inamkesoham5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

Project Report

on

C Program to Implement Online Voting System

Submitted by

Soham Inamke (1032222434)


Tanish Lahamge (1032222298)
Aaditya Chougule (1032232660)

in a course

Data Structures and Algorithms (EEE2005B)

SY B. Tech
Under the Guidance of
(Mrs.Manisha Kowdiki)

Department of Electrical and Electronics Engineering

Dr. Vishwanath Karad


MIT World Peace University, Pune
[2023-2024]

1
Table of Contents

Acknowledgement 1

List of Figures 2
 Online Voting System
Abbreviations 3

1 Introduction………………………………………………………….. 4

2 Aim and Objectives………………………………………………….. 5

3 Problem statement 7

4 Methodology 7

5 Code 9

6 Results 14

7 Conclusion 17

8 Learning outcome 19

9 References 19

2
C Program to Implement Online Voting System

INTRODUCTION
Online voting systems represent a transformative approach to democratic
participation, harnessing the power of technology to modernize the electoral
process. By facilitating remote voting via the internet, these systems offer
unparalleled accessibility, convenience, and security to voters worldwide.

The code presented here lays the foundation for an online voting system,
demonstrating key functionalities essential to its operation. Let's delve into the
core components and principles underlying this innovative platform:

Accessibility and Convenience: Online voting systems break down barriers to


participation by allowing eligible voters to cast their ballots from anywhere with
an internet connection. Through user-friendly interfaces and intuitive design,
voters can conveniently exercise their democratic rights without the constraints of
physical location or time constraints.

Security and Integrity: Central to the design of online voting systems is robust
security measures to safeguard the integrity of the electoral process. The code
implements encryption, authentication mechanisms, and ballot verification
procedures to protect against tampering, fraud, and unauthorized access, ensuring
that every vote is counted accurately and securely.

Verification and Authentication: To maintain the credibility of election results,


online voting systems incorporate rigorous verification and authentication
protocols. These may include biometric verification, digital signatures, or unique
voter identification codes to verify the identity and eligibility of voters,
preventing fraudulent or duplicate votes.

Transparency and Accountability: Transparency is fundamental to instilling trust


in the electoral process. The code enables stakeholders, including election
3
C Program to Implement Online Voting System
officials, candidates, and the public, to monitor and audit the voting process,
ensuring transparency, accountability, and adherence to electoral laws and
regulations.

Scalability and Reliability: Online voting systems are designed to scale


efficiently to accommodate varying numbers of voters and election requirements.
The code demonstrates reliability and resilience, capable of handling high
volumes of traffic and ensuring uptime during critical periods to prevent system
failures or disruptions.

Usability and User Experience: A user-centric approach is paramount to the


success of online voting systems. The code prioritizes usability and user
experience, with intuitive interfaces and clear instructions to guide voters
seamlessly through the voting process, minimizing errors and enhancing overall
satisfaction.

4
C Program to Implement Online Voting System
Aim and Objectives:
The online voting system offers the following functions:
 Taking a Vote from the User
 Storing Different Votes
 Calculating Votes
 Declaring Results

Components of Program
The Online Voting System program has the following components:
1. Header Files and Macro Definitions
 This program makes use of only two standard header files <stdio.h>
and <string.h>.
 We have also defined a macro to represent the maximum number of
candidates.
2. Structure with name “Candidate”
The structure with the name “Candidate” is defined to store the information of
the candidate. It has the following fields:
 name Array: This array of characters is used to store the name of the
candidate.

5
C Program to Implement Online Voting System
 symbol: This character variable stores the symbol allotted to the
candidate.
 votes: This variable is used to store the number of votes that the given
candidate received.
3. Data Structures and Variables with Global Scope
Some of the data structures and variables are declared inside the global scope to
avoid scope problems and make them available to all the functions in the
program. These are:
 allCandidate[]: This array stores all the candidates.
 candidateCount: It is used to store the number of candidates.
 symbol[]: This array is used to store all the symbols.
 symbolTaken[]: Used to keep track of the symbols that are already
allotted to some candidate.
4. Functions to Perform Different Tasks
Various functions are used in the program to provide modularity to the code.
They are named based on the task they are performing:
 fillCandidate(): This function is used to take user input about the
candidate details and store them in the allCandidate[] array.
 displayAllCandidates(): This function is used to display all available
candidates while the voting is being performed.
 getVotes(): This function is used to take the votes from the user and
store them in the structure for the given candidate.
 getResults(): After the voting, the getResults() function is used to
calculate the votes and declare the results of the elections.

6
C Program to Implement Online Voting System

Problem Statement: Development of an Online Voting System

Methodology:
1. Requirements Gathering and Analysis:

Identify the primary objectives and functionality required for the online voting
system.

Define user roles, such as voters, candidates, and administrators, and their
respective responsibilities.

Gather basic requirements, including voter registration, candidate nomination,


ballot casting, and result determination.

2. Design:

Design the data structures and algorithms needed to implement the core
functionalities of the online voting system, such as storing candidate
information, tallying votes, and displaying results.

Define the user interface layout and interaction flow for the web-based
application, considering usability and accessibility principles.

Plan the security measures, authentication mechanisms, and error handling


procedures to ensure the integrity and confidentiality of the voting process.

3. Implementation:

Write the code for the online voting system in C, following best practices for
code organization, readability, and modularity.

7
C Program to Implement Online Voting System
Implement functions for candidate registration, voter authentication, ballot
casting, vote tallying, and result determination according to the defined
requirements and design specifications.

Incorporate error handling mechanisms to manage invalid inputs, handle


exceptions, and ensure the robustness of the system.

4. Testing:

Develop test cases to verify the functionality, correctness, and reliability of the
online voting system.

Conduct unit tests to validate individual components and functions, ensuring


they perform as expected.

Perform integration testing to assess the interaction and interoperability of


different system modules.

Conduct user acceptance testing (UAT) to gather feedback from stakeholders


and ensure the system meets their needs and expectations.

5. Deployment:

Prepare the online voting system for deployment on a web server or hosting
platform.

Configure the necessary server infrastructure, databases, and security settings to


support the operation of the system.

Deploy the system to a production environment, ensuring smooth transition and


minimal disruption to users.

6. Maintenance and Support:

8
C Program to Implement Online Voting System
Provide ongoing maintenance and support for the online voting system,
addressing any issues, bugs, or security vulnerabilities that arise.

Monitor system performance, availability, and security, implementing updates


and patches as needed to ensure its continued operation and reliability.

Respond to user feedback and suggestions for improvements, incorporating


enhancements and new features to enhance the functionality and usability of the
system.

Code:

#include <stdio.h>

#include <string.h>

#define MAX_C 11

typedef struct Candidate {

char name[50];

int votes;

char symbol;

} Candidate;

Candidate allCandidates[MAX_C];

int candidateCount = 0;

char symbols[10] = { '!', '@', '#', '$', '%', '^', '&', '*', '~', '+' };

int symbolTaken[11];

void fillCandidate(int);

void displayAllCandidates();

void getVotes(int);

void getResults();

9
C Program to Implement Online Voting System

int main()

for (int i = 0; i < 11; i++) {

symbolTaken[i] = 0;

printf("Enter the number of candidates: ");

scanf("%d", &candidateCount);

if (candidateCount >= MAX_C) {

printf("Number of candidates cannot be greater "

"than 10.\n Terminating the program\n\n");

return 0;

for (int i = 0; i < candidateCount; i++) {

fillCandidate(i);

int numVoters;

printf("Enter the number of voters: ");

scanf("%d", &numVoters);

for (int i = 0; i < numVoters; i++) {

getVotes(i);

getResults();

10
C Program to Implement Online Voting System
return 0;

void fillCandidate(int cNum)

printf("Available Symbols: \n");

for (int j = 0; j < 10; j++) {

if (symbolTaken[j] == 1)

continue;

printf("%d %c\n", j + 1, symbols[j]);

int num = 0;

printf("\nEnter the symbol number of candidate %d: ",

cNum + 1);

scanf("%d", &num);

if (num <= 0 || num > 10 || symbolTaken[num - 1] == 1) {

printf("This Symbol is not available. Please "

"choose from the available symbols\n");

num = 0;

fillCandidate(cNum);

else {

symbolTaken[num - 1] = 1;

allCandidates[cNum].symbol = symbols[num - 1];

printf("Enter the name of candidate %d: ",

cNum + 1);

11
C Program to Implement Online Voting System
scanf("%s", allCandidates[cNum].name);

allCandidates[cNum].votes = 0;

void displayAllCandidates()

if (candidateCount <= 0) {

perror("Invalid Candidate Array\n");

return;

for (int j = 0; j < candidateCount; j++) {

printf("%s\t\t", allCandidates[j].name);

printf("\n");

for (int j = 0; j < candidateCount; j++) {

printf("%3c\t\t\t", allCandidates[j].symbol);

printf("\n");

void getVotes(int voterCount)

displayAllCandidates();

printf("Voter %d, please enter your choice (1-%d): ",

voterCount + 1, candidateCount);

12
C Program to Implement Online Voting System
int choice;

scanf("%d", &choice);

if (choice >= 1 && choice <= candidateCount) {

allCandidates[choice - 1].votes++;

else {

printf("Invalid choice! Please vote again.\n");

getVotes(voterCount);

void getResults()

int maxVotes = 0;

int winnerIndex = -1;

int winnerFrequency = 0;

for (int i = 0; i < candidateCount; i++) {

if (allCandidates[i].votes > maxVotes) {

maxVotes = allCandidates[i].votes;

winnerIndex = i;

for (int i = 0; i < candidateCount; i++) {

if (allCandidates[i].votes == maxVotes) {

winnerFrequency++;

13
C Program to Implement Online Voting System
}

printf("\n-----RESULT-----\n");

if (maxVotes == 0 || winnerFrequency > 1) {

printf("No candidate has majority votes\n");

else if (winnerIndex != -1) {

printf("The winner is: %s\nCandidate Symbol: "

"%c\nwith %d votes!\n",

allCandidates[winnerIndex].name,

allCandidates[winnerIndex].symbol, maxVotes);

else {

printf("No winner\n");

}
}

Result:
Enter the number of candidates: 3

Available Symbols:

1!

2@

3#

4$

5%

6^

14
C Program to Implement Online Voting System
7&

8*

9~

10 +

Enter the symbol number of candidate 1: 1

Enter the name of candidate 1: Soham

Available Symbols:

2@

3#

4$

5%

6^

7&

8*

9~

10 +

Enter the symbol number of candidate 2: 2

Enter the name of candidate 2: Tanish

Available Symbols:

3#

4$

5%

6^

15
C Program to Implement Online Voting System
7&

8*

9~

10 +

Enter the symbol number of candidate 3: 3

Enter the name of candidate 3: Aaditya

Enter the number of voters: 10

Soham Tanish Aaditya

! @ #

Voter 1, please enter your choice (1-3): 1

Soham Tanish Aaditya

! @ #

Voter 2, please enter your choice (1-3): 2

Soham Tanish Aaditya

! @ #

Voter 3, please enter your choice (1-3): 3

Soham Tanish Aaditya

! @ #

Voter 4, please enter your choice (1-3): 1

Soham Tanish Aaditya

! @ #

Voter 5, please enter your choice (1-3): 2

Soham Tanish Aaditya

! @ #

16
C Program to Implement Online Voting System
Voter 6, please enter your choice (1-3): 3

Soham Tanish Aaditya

! @ #

Voter 7, please enter your choice (1-3): 2

Soham Tanish Aaditya

! @ #

Voter 8, please enter your choice (1-3): 1

Soham Tanish Aaditya

! @ #

Voter 9, please enter your choice (1-3): 2

Soham Tanish Aaditya

! @ #

Voter 10, please enter your choice (1-3): 3

-----RESULT-----

The winner is: Tanish

Candidate Symbol: @
with 4 votes!

Conclusion:

In conclusion, the code provided serves as a testament to the transformative


potential of online voting systems in democratizing access to elections,
enhancing security and integrity, and fostering trust and confidence in the
democratic process. As we continue to advance technologically, online voting
systems stand at the forefront of innovation, shaping the future of democratic
participation worldwide.

17
C Program to Implement Online Voting System

Learning outcome:

1. Programming Concepts:

 Structures and Arrays: Understanding how to use structures and arrays in


C to organize and store candidate information efficiently.

 Input/Output Operations: Practicing input and output operations in C,


including reading user input and displaying information.

 Functions and Recursion: Implementing functions for modular code


organization and recursion for repetitive tasks like error handling.

 Conditional Statements and Loops: Utilizing conditional statements (if-


else) and loops (for) for decision-making and iterative processes.

 Error Handling: Learning error handling techniques, such as recursion, to


manage invalid user inputs and ensure program robustness.

 Security Considerations: Exploring basic security measures, such as


symbol allocation and verification, which are fundamental in online
voting systems.

18
C Program to Implement Online Voting System
 Algorithm Design: Designing algorithms for vote tallying and result
determination, essential skills for processing data and making decisions in
software development.

2. Understanding of Online Voting Systems:

 Accessibility and Convenience: Recognizing the importance of


accessibility and convenience in modernizing the electoral process and
increasing voter turnout.

 Security and Integrity: Understanding the critical role of security


measures, encryption, and authentication mechanisms in safeguarding the
integrity of online voting systems against fraud and tampering.

 Verification and Authentication: Appreciating the significance of robust


verification and authentication protocols to ensure the credibility of
election results and prevent unauthorized access.

 Transparency and Accountability: Acknowledging the necessity of


transparency and accountability mechanisms to foster trust and
confidence in the electoral process among stakeholders and the general
public.

 Scalability and Reliability: Understanding the challenges associated with


scalability and reliability in online voting systems, including handling
high volumes of traffic and ensuring uptime during critical periods.

 Usability and User Experience: Recognizing the importance of user-


centric design principles to enhance usability and user experience,
ultimately improving voter satisfaction and engagement.

19
C Program to Implement Online Voting System
 Legal and Regulatory Compliance: Learning about legal and regulatory
requirements governing online voting systems, including privacy laws,
electoral regulations, and cybersecurity standards.

Reference:

https://www.geeksforgeeks.org/online-voting-system-in-c/

https://github.com/Rajattheonlyhero/Online-Voting-System-Data-Structure-
Projec

20

You might also like