Introduction to Programming Languages
Introduction to Programming Languages
A program is set of instructions that tell the computer what to do. A programming language is a formal
computer language designed to communicate instructions to the machine, particularly a computer.
– High-Level languages
1. Machine Languages
• Comprised of 1s and 0s
• The “native” language of a computer, the language which the computer can understand.
• Example of code:
1110100010101 111010101110
10111010110100 10100011110111
3. High-Level Languages
High-level languages represent a giant leap towards easier programming.
The syntax of HL languages is similar to English.
Needs a compiler or interpreter to convert the source code into machine code.
Historically, we divide HL languages into two groups:
a) Procedural languages
o Early high-level languages are typically called procedural languages.
o Procedural languages are characterized by sequential sets of linear commands. The focus
of such languages is on structure.
o Examples include C, COBOL, Fortran, LISP, Perl, HTML, VBScript, Pascal etc
b) Object-Oriented languages (OOP)
o Most object-oriented languages are high-level languages.
o The focus of OOP languages is not on structure, but on modeling data.
o Programmers code using “blueprints” of data models called classes.
o Examples of OOP languages include C++, Visual Basic.NET and Java.
Interpreter Compiler
Pascal is a procedural High level language. Some of the famous programs written in this language are
Skype and Apple Lisa.
Program Structure
A Pascal program is divided into two main sections-The program header and the instructions block. These
main sections comprise of the following parts:
Program name
Uses command
Constant declarations
Variables declarations
Main program block
Example
Program header
PROGRAM HELLOWORLD;
USES Crt;
(*Variable declaration section*)
VAR ……..; Variable Declaration
……..;
(*instruction block*)
BEGIN
Clrscr;
Instruction Block
Writeln(‘Hello St.Marys’);
Readln;
END.
The first line of the program HellowWorld; indicates the name of the program.
The second line of the program uses crt; is a preprocessor command, which tells the compiler to
include the crt unit before going to actual compilation.
The third line (*Variable declaration section*) is a comment. Comments are messages that
describe what the section of code does and comments are ignored by the compiler.
The next line VAR is a variable statement which is used to tell the compiler to reserve space in
primary memory for the variables which will be used in the program.
The next lines enclosed within begin and end statements are the main program block. However,
the end statement indicating the end of the main program is followed by a full stop (.) instead of a
semi-colon (;)
The reserved word Clrscr; is a procedure that clears the screen for the output
The Writeln(‘Hello St.Marys’); used print out the output on the screen.
Writeln(‘ hello’); will display hello
The Readln; establishes communication between the computer and the user. It allows the
display to pause until the user presses a key. It is part of the crt unit. A unit is like a pascal library.