C Word
C Word
Let me first thank Mr. Sushil Adhikari for his priceless time, wisdom, and
advice. Additionally, I would want to thank Asia Pacific University and the
Infomax College of IT and Management, where I attended college, for giving
me this fantastic opportunity and for establishing an environment that is
ecologically friendly so that I may grow and succeed.
Dipesh Aryal
Abstract
The main characteristics and capabilities of a voting system are outlined in this
assignment. It examines the electoral process for choosing representatives,
approving mandates, reviewing governmental operations, and electing officials.
The abstract explores the key elements of a voting system, such as scheduling
elections, registering candidates, registering voters, updating voter information,
casting ballots, and displaying election results. The assignment emphasizes how
important it is to make voting accessible, accurate, secure, and transparent to
promote a free and democratic election. The assignment seeks to illuminate the
complex workings of voting systems and their crucial influence on the
development of democratic societies.
Table of Contents
1. Voting System:.....................................................................................................................1
2. Presumption:........................................................................................................................ 2
3. Program design:....................................................................................................................3
Pseudocode (P.C):................................................................................................................. 3
Flowchart:.............................................................................................................................4
Main Menu........................................................................................................................... 5
Pseudocode of Main menu:..............................................................................................5
Flowchart for Main Menu:................................................................................................6
Schedule of Election:............................................................................................................ 7
P.C of Schedule of Election:...................................................................................................7
F.C of Schedule of Election:...................................................................................................8
Registration of Candidate:.................................................................................................... 9
P.C of Registration of Candidate:...........................................................................................9
F.C of Registration of candidate:......................................................................................10
Registration of Voter:..........................................................................................................11
P.C of Registration of Voter:.............................................................................................11
F.C of Registration of Voter:.............................................................................................13
Update voter details:.......................................................................................................... 14
Pseudocode of Update voter details:..............................................................................14
Flowchart of update voter details:..................................................................................16
Search voter details:........................................................................................................... 17
Pseudocode of Search voter details:...............................................................................17
Flowchart of search voter details:...................................................................................18
Cast Vote.............................................................................................................................19
Pseudocode of Cast Vote:................................................................................................19
Flowchart of Cast vote.................................................................................................... 22
Vote Result..........................................................................................................................23
Pseudocode of vote result...............................................................................................23
Flowchart of Vote Result:................................................................................................24
Exit System..........................................................................................................................25
Pseudocode of Exit system:.............................................................................................25
Flowchart of Exit system:................................................................................................ 25
4. Basic Concepts of C.............................................................................................................26
The voting system uses the following fundamental C programming language concepts:...26
Variables............................................................................................................................. 26
Input Output.......................................................................................................................26
Comments.......................................................................................................................... 27
5. Intermediate concepts of C................................................................................................ 28
The voting system uses the following intermediate C programming language concepts:...28
Control Structures...............................................................................................................28
Conditional:.....................................................................................................................28
Loop:............................................................................................................................... 29
File handling:...................................................................................................................... 29
Array:.................................................................................................................................. 29
String:................................................................................................................................. 30
6. Advanced concepts of C..................................................................................................... 31
Function.............................................................................................................................. 31
Standard library functions.................................................................................................. 31
User defined functions........................................................................................................32
Function Prototype:........................................................................................................ 32
Function Call:.................................................................................................................. 32
Function Declaration:......................................................................................................32
Pointers...............................................................................................................................33
Structures........................................................................................................................... 33
Files.....................................................................................................................................33
7. Additional Features:........................................................................................................... 34
8. Limitations..........................................................................................................................34
9. Sample output....................................................................................................................35
10. Conclusion........................................................................................................................ 37
References.............................................................................................................................. 38
1. Voting System:
A voting system that enables citizens to exercise their right to participate in
government and select the leaders of their nation is the cornerstone of
democratic societies.. A voting system's fundamental function is to offer a
formal framework through which voters may express their opinions on a range
of subjects, choose leaders, and influence policy.
1
2. Presumption:
Fundamental components of problem-solving, decision-making, and
communication are assumptions. In essence, they are presumptions or beliefs
that we hold to be true even if they may not be explicitly supported or validated.
In many areas, including science, business, technology, and daily life,
assumptions are important.
2
3. Program design:
When creating a program in C, you organize and organize your code to carry
out a certain task quickly and correctly. Here is a step-by-step manual to assist
you in creating a C program: The planning and development of a software
program or application is referred to as program design. It entails making
calculated choices about the organization of data, the use of algorithms, and the
layout of the code to solve a given issue or accomplish a certain objective. For
software to be manageable, efficient, and resilient, it must be designed well.
Pseudocode (P.C):
Pseudocode is a technique for expressing computer code and algorithms in
languages other than their native programming language, like English. It is a
description of what the code should perform rather than the code itself.
For example.
3
Flowchart:
A flowchart is a visual depiction of the order of operations or processes in a
computer program, operating system, or algorithm. The control and data flow
inside a process are represented by standardized symbols. Here is an illustration
of how you may make a straightforward flowchart for a program that
determines the area of a rectangle:
For e.g.
4
Main Menu
From the main menu, users may choose from a number of alternatives to carry
out tasks pertaining to elections, candidates, voters, and voting outcomes.
5
Flowchart for Main Menu:
6
Schedule of Election:
The election schedule is about handling the voting system's election timetable.
7
F.C of Schedule of Election:
8
Registration of Candidate:
This will register candidates by asking their name, political party and
candidancy from.
11
12
F.C of Registration of Voter:
13
Update voter details:
This helps to update voter names, addresses, and all registered details of voters.
14
15
Flowchart of update voter details:
16
Search voter details:
This will search voter details after getting voter’s SNO.
17
Flowchart of search voter details:
18
Cast Vote
Casting vote is the main feature of voting system where voters will login
themselves and choose candidate for voting.
19
20
21
22
Flowchart of Cast vote
23
Vote Result
The result is announced after one became the winner by some margins of vote.
24
Flowchart of Vote Result:
25
Exit System
This helps voters to exit from the system.
26
4. Basic Concepts of C
The voting system uses the following fundamental C programming language concepts:
Variables
A program can change data by designating a specific region of memory as a variable in C.
This is where the variable's value is stored. The C variable's value might be changed by the
program. Any data type, such as int, float, char, etc., may be used as a variable in C.
For e.g.
Int voterSNO;
At this point the data type int is used to store values as integers, and voterSNO is a variable.
Input Output
The terms "input" and "output" in C programming relate to the operations of receiving data
from the user (input) and showing information to the user (output) via various channels.
These procedures are necessary for developing engaging programs. For e,g,
pcanf("%s",Name);
At this point printf demands the user's input for the voter's name whereas scanf accepts a
character for the voter's name.
27
Comments
The text notes known as comments are used in C programming to provide explanations,
notes, or documentation to the source code. The compiler ignores comments; thus they have
no impact on how the code will run. For e.g
28
5. Intermediate concepts of C
The voting system uses the following intermediate C programming language concepts:
Control Structures
These are programming elements that let you direct how your program runs in C. You may
make judgements, take conditional action, and repeat tasks thanks to them. The fundamental
control structures in programming language are as follows.
Conditional:
which, if a condition is true, causes one or more statements to be executed. Examples are
like; if, if-else, etc.
For e.g,
29
Loop:
A statement is meant to be repeated a certain number of times or while a condition is met in a
loop. Examples include "do," "while",”for” etc.
For e.g,
File handling:
Working with files to read or write data is known as file handling. Because it calls for a
greater knowledge of how to interact with files, open them, read data from them, write data to
them, and handle file pointers, it is classified as an intermediate notion. For e.g.
if (found_voter.sno! = -1) {
printf ("Voter Found:\n");
printf("Voter SNO: %d\n", found_voter.sno);
printf ("Name: %s\n", found_voter.name);
printf ("Date of Birth: %s\n", found_voter.dob);
printf ("Address: %s\n", found_voter. Address );
printf ("Password: %s\n", found_voter. password);
} else {
printf ("Voter not found.\n");
}
Array:
Programmers can store several items of the same kind under the same variable name by using
an array, a sort of data structure. For the initial element in the array, the index used to identify
it is 0, and it increases from there. For.eg.
char Names[4][100];
30
String:
Strings are collections of characters that represent text in C programming. An array of
characters that ends in the null character ('0') is how a string is normally stored. In C, strings
are used to manipulate textual data and are a crucial component of many programs.
For E.g.
31
6. Advanced concepts of C
The voting system uses the following sophisticated C programming language concepts:
Function
A function is a section of code that carries out a particular purpose in C programming. By
enabling you to divide a program into more manageable, smaller parts, functions promote
modularity and code reuse. They also encourage greater organization and make it simpler to
maintain the code.
For e.g
printf("\n * * ");
printf("\n * Voting system * ");
printf("\n * * ");
32
User defined functions
To complete tasks, the programmer builds user-defined functions. They enable you to
organize and make your code more understandable and modular.For e.g.
Function Prototype:
void ElectionSchedule();
Function Call:
ElectionSchedule();
Function Declaration:
void ElectionSchedule()
{
printf("Election Schedule...\n");
FILE* fp = fopen("schedule.txt", "w");
int date,year,month,day;
char Constituency[55];
char choice;
do
{
printf("\n Enter Schedule of Election:\n");
printf(" Constituency: "); scanf("%s", &Constituency); fflush(stdin);
printf(" DOE:");scanf ("%d-%d-%d", &year, &month, &day); fflush(stdin);
fprintf(fp, "%s %d-%d-%d\n", Constituency,year,month,day);
printf("\n Election Schedule has been stored in schedule.txt file.\n");
printf(" Do You want to insert more? [y.YES/n.No]: ");
scanf(" %c", &choice);fflush(stdin);
}
while (choice == 'y');
fclose(fp);
}
33
Pointers
In C, pointers are a basic and potent feature that make it possible to manage data and handle
memory in a more flexible and effective way. A variable called a pointer effectively points to
another variable's position in memory by storing its memory address. Through this, you may
edit and indirectly access the data kept at that memory location.
File pointer
Structures
A structure in the language C is a composite data type that unifies variables of several data
kinds under a single name. With the aid of structures, you may design your own unique data
types that can store several connected bits of data. For e,g.
struct date {
int year, month, day;
};
Files
Both input and output procedures need files. You can read data from outside sources (like text
files) and send data to outside destinations using files. You can open, read, write, and close
files using the functions for working with files provided by the C standard library.
For e.g.
34
7. Additional Features:
A voting system, which enables individuals to voice their choices and ideas in various
elections, is an essential part of democratic processes. Here are some essential characteristics
of a voting system:
Accessibility: All eligible voters, including those who are disabled, speak a foreign
language, or have other special requirements, should be able to use the voting system. No
voter should be denied the right to vote because of accessibility restrictions.
Accuracy: To represent the actual intentions of the voters, the system should correctly
record and tally votes. This involves reducing the chance of fraud, preserving vote
integrity, and preventing mistakes.
Security: Strong security measures should be incorporated into voting systems to prevent
hacking, manipulation, or unauthorized access to voter data and results.
Easy of use: The voting procedure should be as simple as possible for voters, minimizing
misunderstanding. Easy-to-use features include clear directions, user-friendly interfaces,
and staff that have received the required training.
Reliability: The system needs to be dependable and strong, preventing technological
problems and guaranteeing the availability of materials needed for voting (such as
functional voting machines and enough ballots). (YesElections, 2020)
8. Limitations
These are some typical voting system limitations:
Lack of Transparency: Online voting may potentially be less transparent than traditional
methods. Voters can use a conventional paper ballot and see the ballots being tallied.
However, since online voting is entirely electronic, it is more challenging to determine the
results. (Otsuka, 2023)
35
9. Sample output
Here are some glimpses of Voting system.
Main Menu
Casting Vote
36
Figure: Cast Vote
Txt files:
Vote Result:
Above figures only show main menu, casting vote and vote result to display the samples of
my code where Shyam won it with 1 vote.
37
10. Conclusion
The assignment was concluded by giving a thorough review of the essential components of a
voting system. I appreciate the value of ongoing adjustments to accommodate changing
requirements and technical breakthroughs by being aware of the difficulties and constraints.
Through this project, I have developed a deeper understanding of the crucial role that these
systems serve in sustaining democratic ideals and encouraging public participation in
government.
References
38
Fresh2Fresh. (2022, September 22). Retrieved from Fresh2Fresh website:
https://www.fresh2refresh.com/c-programming/c-variables/
39