0% found this document useful (0 votes)
6 views

C Final

This document describes the design and implementation of a voting system program created using C programming language. It includes: 1) An introduction describing the system allows an admin to manage candidates and voters can vote for candidates. 2) Design assumptions and pseudo code/flowchart of the program. 3) Explanations of the header file, C source code files with inputs/outputs, and code to create election schedules. 4) Details on the admin panel source code for candidate registration, updating candidates, and deleting candidate details. The program allows an admin to register candidates, create election schedules, and manage candidate details after verifying their credentials. It stores candidate and voter information in text files.

Uploaded by

budhah282
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

C Final

This document describes the design and implementation of a voting system program created using C programming language. It includes: 1) An introduction describing the system allows an admin to manage candidates and voters can vote for candidates. 2) Design assumptions and pseudo code/flowchart of the program. 3) Explanations of the header file, C source code files with inputs/outputs, and code to create election schedules. 4) Details on the admin panel source code for candidate registration, updating candidates, and deleting candidate details. The program allows an admin to register candidates, create election schedules, and manage candidate details after verifying their credentials. It stores candidate and voter information in text files.

Uploaded by

budhah282
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 33

Table of Contents

1.0 Introduction.........................................................................................................................................3

2.0 Assumption...........................................................................................................................................3

2.0 Design of a program............................................................................................................................4

2.1 Pseudo code of a program...............................................................................................................4

2.2 Flowchart of a program................................................................................................................15

3.0 Explanation of program source code with sample input and output.............................................17

3.1 Header File Source code................................................................................................................17

3.2 C files source code with sample inputs and outputs....................................................................18

3.3 Sourced code to create election schedules....................................................................................19

4.0 Admin Panel.......................................................................................................................................20

4.1 Source Code of Candidate Registration.......................................................................................23

4.2 Source code of updating the Candidate........................................................................................28

4.3 Source code of delete and display the candidate's details...........................................................30

5.0 Conclusion..........................................................................................................................................31
1.0 Introduction
The voting system is a system designed for the APU university using the C programming
language. The C programming language is used in creating the program using the software
known as Dev C++. The voting system contains several users such as the admin who serves as a
manager, the candidate who elected the election, and voters who vote for the candidates.
The system allows the admin to add, delete, and update the candidate's details. Admin has a
username and password. The user entered the defined username and password to access the
admin function.

2.0 Assumption
There are several assumptions while designing the program. The voting system is programmed to
store the candidate’s details and voter details. The candidate’s details include the Candidate's ID,
Name, political party, and candidacy. The voter’s details include voter ID, name, address, and
password. In the admin function, user-defined the username and password. If the user wants to
edit the candidate, a user should enter the username and password after he or she accesses the
program.
2.0 Design of a program.
2.1 Pseudo code of a program
2.2 Flowchart of a program
Main program and Menu function flow chart.
3.0 Explanation of program source code with sample input and output
3.1 Header File Source code

In general, the header files contain function declarations, data types, and preprocessor
commands. This code also contains the structure where multiple data types are stored in the
suitable variable. After that code, declarations can be done. We all declare the necessary
functions that are needed to execute the program. The header file ’include<stdio.h>’ allows us to
use ‘printf()’ and ‘scanf()’ for input and output operations. Without these header files, the
compiler can’t compile the program. The other header file “#include<string.h>” is used to
manipulate the string function in the program. These functions include strcpy(), strlen(), strcmp()
etc. The structure ‘electionschedule’ is created to hold the information related to the election
schedule including the name of consistency (‘consistency’) and (‘DateOfElection’).
Similarly, the other structures are (‘Voter_Registratioin’) and (‘Candidate_Registration’) which
are designed the store multiple data related to their voter registration and candidate registration
respectively. We all declared so many functions such as admin(), candidate(), electionSchedule(),
VoterRegistration() and remaining functions are in the above program.

3.2 C files source code with sample inputs and outputs


In the above program, I’m trying to make a menu function where users can choose
different options based on their roles. If a user is a candidate, S/he can press 1
button. Again, if a user is a voter, she/he can press the button 2. Similarly, if a user
is an admin, she/he can press the button 3.

fig 2: menu printed test on the menu


fig 2: negative test printed on the screen.

Fig 1 shows that the Switch case statement allows the user to select options 1 to 5 based on their
roles. If users want to exit the program, she/he can press button 5’ exit the program’. Fig 2
shows that if a user can’t select the options between 1 and 5, an invalid choice is displayed on the
screen. Similarly, when users press the button between 1 to 4, it goes to functions like
admin(),voterRegisteration(),candidate(), and displayVoteresult().

We go sequentially.

3.3 Sourced code to create election schedules.


Before creating the elections, only the admin can create the election schedule. So, the admin
function will be declared first. In the admin function, if the admin doesn't know their admin
username and password, they can’t access the program. Admin verification failed is coming on
the screen. That’s why, if admin wants to create the election schedule, they should enter the
defined username and password at the first of the function.
4.0 Admin Panel

Fig 4: admin verification

fig: a negative test of admin verification

The admin username and password are defined at the first of the function. If the above username,
password, and the user's entered username, and password are not the same. It displayed admin
verification failed on the screen. If users want to create the election schedule, they entered right
username and password.

fig 5: admin verification.


If users entered the same username and password as compared to the defined username and
password at the top of a program, it displayed admin verification successfully on the screen.
Then only the admin can be allowed to create an election schedule and edit the candidates.

Fig Source code of admin()

The above code in the figure uses the switch case statement to choose selections 1 to 3 whether
to create an election schedule, edit candidates, or exit the program. If the admin wants to create
the election schedule, he/she should press button 1 to enter the election schedule functions

Fig source code of election schedule

The above code in this figure when users want to create the election schedule, they enter the
information related to the election schedule including consistency and date of election. After
entering the information related to the schedule, this information will be stored in schedule.txt.
if users want to store the information in the file, he/she creates the file, open its file in append
form, and close its file. After that, the information will be stored in that file.

Fig : Information of election schedule.


When the above program is executed, users can enter the information based on the question. In
the above program, a user enters the consistency and date of election. This information is stored
in the schedule.txt file.

fig: schedule.txt file

This is the file where information is stored.

4.1 Source code of Candidate Registration.


After creating the election schedule, users want to register the candidate for the election
sequentially. If the user wants it, he or she exits the admin function. Again, go to the main
function.
The function is meant to register the candidate by entering their information, such as their ID,
name, political party, and candidacy form. After the registration, this information should be
stored in candidatelist.txt. First, the users should enter the number of candidates and how much
they need to store. If a user entered 3 number candidates, it stored only 3 candidate’s
information.

Fig: output screen of candidate information

In the above figure, the candidate entered their information based on the data types. After
entering, the candidate should be registered successfully. After the registration, all information is
stored in the candidatelist.txt file because the user creates a file candidate, opens it as append
mode, stores the information in that file, and then closes it file.

fig : candidatelist.txt

This is the candidatelist.txt where the candidate’s information are stored in this file.

According to the question, only the admin can add, update, and delete the candidates. After the
candidate registration, a user should go to the admin function to edit the candidates. It uses a
switch case statement where have to select edit candidates function whether to add, delete or
update the candidates.

Source code of add the candidates.


Fig source code add candidate ()

In the above figure, this function operates to add the information of candidates such as ID, name,
political party, and candidacy. The function starts by declaring a file pointer candidate to FILE.
The file pointer is opened for appending mode and the writes user inputs information to store in
the candidatelist.txt.

Fig: adds the candidate on the screen

In this output, the program asked the registered about the information of the new
candidate and added it to the file.
Fig: add candidate on candidatelist.txt.

After entering the information about the new candidate, this information will be
stored in a file. Only the admin can add the candidate information.

4.2 Source code of updating the candidate


Fig: source code of updating the candidate
In the above code, only the admin can update the candidate's details. The function update is
meant to update the candidate’s details. At first, a new ID should be declared to check which
candidate’s details to be updated. A new name, new political party, and new candidacy should be
declared to update the details. The string function ‘strcpy()’ is used to copy the new details to
existing details. Then the file pointer candidate is declared The file is opened for appending
mode. The data are stored in the file.
After entering the updated details, the details are stored in the candidatelist.txt. when all
information is entered, the candidate updated successfully should be displayed on the screen.
Only the admin can update the candidate’s details.

In the file, the candidate’s details should be updated successfully.

4.3 Source code of delete and display the candidate's details.


5.0 Conclusion
In conclusion, building the voting system was a big project involving a lot of things like
making it safer, faster, and easier to use. We added features to handle errors, protect
passwords, and organize the code better. Making sure passwords are hidden when typed
adds an extra layer of protection for personal info. Plus, we made it do cool things like
automatically generating voter numbers, showing candidate lists, and letting admins see
all voter details. These changes make the system work better, be more reliable, and give
users a smoother experience, making it a strong tool for democracy.

You might also like