welcome to episode 2 of pascal programming language tutorial. as i say in my first episode. in this episode i'm going to teach you the structure of a program, and how to make a simple program
- first go to your fpc, file -> new
- here are the structure of a code.
i'm going to break it down one by one
the first one is program. program is used to tell what your name of the program is. as simple as that.
the second thing is var. var is a function used to declare any variable you want to use later in the code.
the third thing is begin and end. this is used as a block. so the computer knows where the program start. and when it ends.
this is an example of a simple program works. i'm going to make a program to add 2 numbers together
as you can see. the first thing to do is make a program and then put your program name in
next is the variable im using is a and b. where a and b are integers
next i write read(a) which means this program has to take user input in the form of integer. and save the value to the variable a
the same thing happen to read(b)
next i write write (a+b) which litterally just meant to print out the sum of a and b as easy as that
after writing all this code. compile by pressing f9 if this is your first compile, then give the name to this file and press ok
if you have compiled your code successfully, then this message will appear
after compiling, you can press ctrl+f9 to open the program. it should look something like this
now remember. the first thing you want this program to do is get an input for the variable a and b so you can write an integer number for a and b. i'm using 10 and 5
then press enter. the program will gone. but don't worry. you just need to press alt+f5 then the result will appear like this
and then you are done. thats how simple it is to make a program
now try to make a subtraction (-) multiplication (*) and division (/)
thats it for now thanks for reading