0% found this document useful (0 votes)
5 views44 pages

C Word

Uploaded by

Quadra Gaming
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)
5 views44 pages

C Word

Uploaded by

Quadra Gaming
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/ 44

Acknowledgement

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.

A voting system's main objective is to provide an accurate, transparent, and fair


reflection of the people's will. Citizens have the chance to participate in the
democratic process and help build a government that reflects their beliefs and
goals through a well-designed voting system.

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.

Following are some assumptions of voting system:

 Admin can set schedule for election.


 Candidates can register for election with name, political party and
candidacy given address.
 Also, admin can register voters with their name, SNO, date of birth,
address, and password.
 Search voters and update voters’ details menu is available.
 Mainly, Voters can login themselves and can cast vote for their
representatives.
 The voting result will be published once the voting is done and winner will
be displayed with his/her respective votes.
 And, then the exit system allows to exit from voting system.

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.

Pseudocode of Main menu:

5
Flowchart for Main Menu:

6
Schedule of Election:
The election schedule is about handling the voting system's election timetable.

P.C of Schedule of Election:

7
F.C of Schedule of Election:

8
Registration of Candidate:
This will register candidates by asking their name, political party and
candidancy from.

P.C of Registration of Candidate:

F.C of Registration of candidate:


9
10
Registration of Voter:
A method to enter and save data of new voters who are qualified to cast ballots.
To keep an accurate and current voter registration, the procedure entails
gathering voter information, authenticating the information, assuring
uniqueness, updating the database, and giving confirmation messages.

P.C of Registration of Voter:

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.

Pseudocode of Update voter details:

14
15
Flowchart of update voter details:

16
Search voter details:
This will search voter details after getting voter’s SNO.

Pseudocode of Search voter details:

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.

Pseudocode of Cast Vote:

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.

Pseudocode of vote result

24
Flowchart of Vote Result:

25
Exit System
This helps voters to exit from the system.

Pseudocode of Exit system:

Flowchart of Exit 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.

 The variable's name must begin with a letter or underscore.


 For variables, case sensitivity is applicable.
 They may be created using either letters or numbers.
 There are no other special characters permitted than underscore.
 The following are some examples of variable names: value, total, and height.
(Fresh2Fresh, 2022)

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,

printf(" Name of Voter: ");

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

char Names[4][100]; // Assuming it have a maximum of 4 candidates

Here, this is the single line comment.

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,

For(i = 0; i < 4; i++)


{
CHAR name [100];
fscanf(voteCountFile, "%[^:]: %d\n", name, &votecounts[i]);
strcpy(candidateNames[i], name);
}

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.

printf("\n Enter details of candidate:\n");


printf(" Name of Candidate: "); scanf("%s", &Name); fflush(stdin);
printf("Political Party: "); scanf("%s", Politicalparty); fflush(stdin);
printf("Candidancyfrom: "); scanf("%s", CandidancyFrom); fflush(stdin);

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.

Standard library functions


The C standard library, a collection of functions and macros that is a component of the C
programming language specification, provides predefined functions in the form of standard
library functions in C. These procedures vary from straightforward input and output actions
to intricate string manipulations and computations.

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

File* fp=fopen(“schedule.txt”, “w”);

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.

Fprintf (fp, "%s %d-%d-%d\n", Constituency, year, month, day);

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:

Complexity and Confusion: Voter confusion brought on by complicated voting procedures or


ballot designs might result in mistakes or unintended ballot spoilage. To reduce uncertainty,
clear instructions and user-friendly interfaces are crucial.

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

Figure: Main Menu

 Casting Vote

Figure: Candidate choice

36
Figure: Cast Vote

 Txt files:

 Vote Result:

Figure: 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/

GeeksforGeeks. (2023). Retrieved from GeeksforGeeks website: https://www.geeksforgeeks.org/c-


pointers/

Otsuka, G. (2023, May 23). ElectionBuddy. Retrieved from ElectionBuddy website:


https://electionbuddy.com/blog/2022/04/20/the-advantages-and-disadvantages-of-online-
voting-systems/

studycom . (n.d.). Retrieved from studycom website: https://study.com/learn/lesson/pseudocode-


examples-what-is-pseudocode.html

YesElections. (2020, 11 12). Retrieved from YesElections website:


https://www.yeselections.com/blog/top-features-online-voting-system

39

You might also like