Final_pps_ruthvik_6669[1]
Final_pps_ruthvik_6669[1]
Report on
ELECTION VOTING
BACHELOR OF TECHNOLOGY
In
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
(AI&ML)
By
ANJUKANDI RUTHVIK
ROLL NO: - 24K81A6669
Under the esteemed guidance of
1
St. MARTIN’S ENGINEERING COLLEGE
UGC AUTONOMOUS
NBA & NAAC A+ Accredited
Dhulapally, Secunderabad – 500100
CERTIFICATE
This is to certify that the PROGRAMMING FOR PROBLEM SOLVING PROJECT
entitled “ELECTION VOTING” is a Bonafide record of independent work done by
ANJUKANDI RUTHVIK (24K81A6669) under my supervision and guidance,
submitted to St. MARTIN’S ENGINEERING COLLEGE, Hyderabad, in partial
fulfilment for the award of the Degree of Bachelor of Technology in COMPUTER
SCIENCE ENGINEERING (AI&ML).
…………………………….. …………………………………
Group Director
(Dr. P. SANTOSH KUMAR PATRA)
2
ABSTRACT
This C programming project focuses on the development of an Election Voting System,
providing a robust and efficient solution for conducting electronic voting processes. The
program encompasses key features such as candidate registration, voter authentication, ballot
casting, and result tabulation. Utilizing fundamental concepts of C programming, the system
employs data structures, file handling, and conditional statements to ensure the integrity and
security of the electoral process. The implementation follows a modular approach, promoting
code reusability and maintainability. This project serves as a practical illustration of how C
programming can be employed to address the complexities of election systems, balancing
simplicity and functionality while adhering to the principles of secure and transparent voting
processes.
3
CONTENTS
ABSTRACT 3
CHAPTER 1 - APPROACH 5
CHAPTER 5 - CONCLUSION 12
4
1. APPROACH
To design a C program for election voting, you can follow a simple approach that allows
multiple candidates, collects votes from users, and outputs the results. Here's an outline for
how you can structure your program:
Steps to Approach
o Ensure user input is valid (e.g., voters can’t vote more than once).
o Register votes.
4. Flow Diagram:
5
2. SYSTEM IMPLEMENTATION
To implement a full voting system in C, we can extend the previous basic program into a
more robust Election Voting System that includes the following features:
System Requirements:
6
3. COMPLETE PROGRAM
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// Define a structure for a candidate
typedef struct
{
char name[50];
int votes;
}
Candidate;
// Function to display the list of candidates
void displayCandidates(Candidate candidates[], int numCandidates) {
printf("Candidates:\n");
for (int i = 0; i < numCandidates; i++) {
printf("%d. %s\n", i + 1, candidates[i].name);
}
printf("\n");
}
// Function to cast a vote
void vote(Candidate candidates[], int numCandidates) {
int choice;
printf("Enter the number of your chosen candidate: ");
scanf("%d", &choice);
if (choice >= 1 && choice <= numCandidates) {
candidates[choice - 1].votes++;
printf("Vote cast successfully!\n");
} else
{
printf("Invalid choice. Please try again.\n");
7
}
}
// Function to display the election results
void displayResults(Candidate candidates[], int numCandidates) {
printf("Election Results:\n");
for (int i = 0; i < numCandidates; i++) {
printf("%s: %d votes\n", candidates[i].name, candidates[i].votes);
}
}
int main() {
int numCandidates;
printf("Enter the number of candidates: ");
canf("%d", &numCandidates);
// Allocate memory for the candidates
Candidate *candidates = (Candidate *)malloc(numCandidates * sizeof(Candidate));
// Get the names of the candidates
for (int i = 0; i < numCandidates; i++) {
printf("Enter the name of candidate %d: ", i + 1);
scanf("%s", candidates[i].name);
candidates[i].votes = 0;
}
int choice;
do
{
printf("\nElection Voting System\n");
printf("1. Display Candidates\n");
printf("2. Cast Vote\n");
printf("3. Display Results\n");
printf("4. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice)
8
{
case 1:
displayCandidates(candidates, numCandidates);
break;
case 2:
vote(candidates, numCandidates);
break;
case 3:
displayResults(candidates, numCandidates);
break;
case 4:
printf("Exiting the program. Thank you!\n");
break;
default:
printf("Invalid choice. Please try again.\n");
}
}
while (choice != 4);
// Free allocated memory
free(candidates);
return 0;
}
9
4. OUTPUT
OUTPUT 1:-
OUTPUT 2:-
10
In the first output I took the no.of candidates as 5 and listed them as
1.ram
2. mahi
3.varma
4.mani
5.venkat
Then according to the program it asks about the no.of voters
It was listed as 5
Voter1
Number of the candidate you want to vote for: -
3
Vote cast successfully for Varma
In this manner I entered the data for 5 voters and got the final output as
1.ram: 2votes
2.mahi: 2votes
3.varma: 0votes
4.mani: 1votes
5.venkat: 0votes
As for the second output the no.of candidates was taken as 3 and the no.of voters as 2.
11
5. CONCLUSION
12
6. FUTURE ENHANCEMENT
In this project of election voting process when compared to the modern way of coding
included it has high security and greater enhancement of a single person. In this way we can
maintain irregularities and maintain the errors to minimum. In this way in the future this code
will be in greater advantage since this program was developed using today’s modern
problems. As for the future enhancement the program allows to change the code accordingly
in case in case of any errors or enhancement in the code.
13