Online Pascal Compiler

{ This program takes a number of candidates and the votes they received in a election, and displays their data. Also, it finds out the winner of the election. Input: Candidate's name and the votes they got Output: Formatted data, total votes, and the winner's name Author: Dipiksha Shrestha } Program ElectionResults(output); Uses sysutils; // to use the format feature var count: integer = 0; i: integer; candidates: array[1..10] of string; votes: array[1..10] of integer; percent_array: array[1..10] of double; total_votes: integer = 0; max: double=0; indexOfWinner: integer= 0; procedure read_data(); { This procedure reads the data from the STDIN and saves them into their respective data-structures } var can_name: string; // name of the candidate vote: integer; // The vote they received begin for i := 1 to count do begin readln(can_name); {saves the candidates name into the variable} readln(vote); {saves the candidates votes into the variable} candidates[i] := can_name; {variable is stored in an candidates array} votes[i] := vote; {variable is stored in an votes array} // the total votes is calculated total_votes := total_votes+vote; end; end; procedure find_winner(); { This procedures finds the candidate who has the maximum votings } begin for i := 1 to count do begin // calculates the percentage of the votes they received percent_array[i] := (votes[i]/total_votes)*100; if((votes[i]/total_votes)*100>max) then // saves it to the max variable if it is the highest max := (votes[i]/total_votes)*100; end; end; procedure winner_name(); { Finds the name of the winning candidate based on the index of the winning percentage } begin for i := 1 to count do begin if(percent_array[i]=max) then indexOfWinner:=i; end; end; procedure write_output(); { This procedure writes the output to the screen in the formatted way. It includes the candidate name, their vote count, and the percentage. } begin for i := 1 to count do begin // Using Format to make the text visually appealing write(Format('%0:-30s', [candidates[i]])); write(Format('%d', [votes[i]])); writeln(Format('%25.2f', [percent_array[i]])); end; end; begin // Saves the total number of candidates into the variable, count readln(count); // The header of the output text writeln('Candidate' + ^i+ ^i+ ' Votes Received' + ^i + ^i +' % of Total Votes'); { Respective procedures are called that help read the data inputted by the user, save them, and display the result } read_data(); find_winner(); winner_name(); write_output(); // Remaining footer of the display text shown as output write('Total '); writeln(Format('%29d',[total_votes])); writeln('The winner of the election is ' + candidates[indexOfWinner] + '.'); end.

About Online Pascal Compiler

Try our Online Pascal Compiler (Version Free Pascal v3.0.2) to Edit, Run, and Share your Pascal Code directly from your browser. This online development environment provides you the latest version Free Pascal v3.0.2.

How to use Online Pascal Compiler?

Write and Execute Code

  • Write your program (or, paste it) directly under the "Source Code" tab.
  • If you want to save your program, go to the "Project" menu and save it.
  • You can directly execute your program without saving it by clicking on on "Execute" button.

User Input

The latest version of Coding Ground allows to provide program input at run time from the termnial window exactly the same way as you run your program at your own computer. So simply run a program and provide your program input (if any) from the terminal window available in the right side.

Online Pascal Compiler: Keyboard Shortcuts

The following are the keyword shortcut of this Online Pascal Compiler:

ShortcutDescription
⌘ + EnterRun the program
⌘ + SSave Project (Login Required)
⇧ + ⌘ + SSave As Project
⌘ + PNew Project
⌘ + GShare Project
⌘ + ZUndo Editing
⌘ + YRedo Editing
⌘ + ASelect All Text
⌘ + XCut Selected Text
⌘ + CCopy Selected Text
⌘ + VPaste Copied Text
⌘ + FSearch Text
⌘ + ⌥ + FReplace Text
ShortcutDescription
Ctrl + EnterRun the program
Ctrl + SSave Project
Shift + Ctrl + SSave As Project
Ctrl + GShare Project
Ctrl + ZUndo Editing
Ctrl + YRedo Editing
Ctrl + ASelect All Text
Ctrl + XCut Selected Text
Ctrl + CCopy Selected Text
Ctrl + VPaste Copied Text
Ctrl + FSearch Text
Ctrl + HReplace Text

Online Pascal Compiler: Save and Share Pascal Code (Project)

Save Pascal Project Online

You can save your Pascal Project with us so that you can access this project later on. To save a project you will need to create a login Id with us. So before you save a project, please create a login Id using a link given at the top right corner of this page.

Share Pascal Project Online

You can use this feature to share your Pascal Code with your teachers, classmates and colleagues. Just click Share Button and it will create a short link, which can be shared through Email, WhatsApp or even through Social Media. A shared link will be deleted if it has been passive for almost 3 months.

More Features of Online Pascal Compiler

  • Theme – You can change the current editor's theme from the "Editor Theme" option under "Settings" menu.
  • Font Size – You can change the font size of the editor /compiler from from the "Font Size" option under "Settings" menu.
  • Tab Size – You can change the tab size from the "Tab Size" option under "Settings" Menu.
  • Show/Hide Line Numbers – You can show/hide the line number with the code from the "Show Line Numbers" or "Hide Line Numbers" option under "Settings" Menu.
  • And, many more.

Benefits of Using Online Pascal Compiler

There are several benefits of using the Online Pascal Compiler to run your Pascal code:

  • Platform independence: You can run your code from any device without taking care of operating systems.
  • Convenience: You don't need to install anything for using this.
  • No setup required: There is no need for additional setup to run your code.
  • Updated version: Our online compiler/editors/terminals are the latest up-to-date.
 Execute |  Beautify | Share
My Projects
Change Password
My Profile
Logout
Undo
Redo
Cut
Copy
Paste
Delete
Select All
Find
Find and Replace
Editor Theme
Crimson
Eclipse
Github
Solarized
Cobalt
krTheme
Monokai
Terminal
Textmate
Twilight
Vibrant Ink
Font Size
8px
9px
10px
11px
12px
13px
14px
15px
16px
17px
18px
20px
22px
24px
Tab Size
1
2
3
4
5
6
7
8
Show Invisible
Hide Invisible
Show Line Numbers
Hide Line Numbers
Ace Editor (Default)
Vim Editor
Emacs Editor
Open New Project
Save Project
Save As New Project
Share Project
Search Project
Online Java Compiler
Online Python Compiler
Online C++ Compiler
Online CSharp Compiler
Online C Compiler
Online PHP Compiler
Online R Compiler
Online NumPy Compiler
More Compilers