Pascal - SPLessons

Pascal Basic Program

Home > Lesson > Chapter 3
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

Pascal Basic Program

Pascal Basic Program

shape Description

The programming syntax for the pascal is very simple when compared to other languages and every coding language will have variables and functions etc. The following is the syntax for the pascal code. [c] program program name uses libraries begin coding block end [/c]

Programming Elements

shape Description

Every coding language will have the following elements.

Data Types

Every programming language consists of some kind of data. Datatype shows the specific data entered into a program. The data types are the keywords used to declare the type of the variable used in the program such as integer, real, character and string. The following is the syntax. [c]variable :datatype=value;[/c]

Variables

The different memory locations where data resides are called objects. To access such an object it must have a name, and such a named object is called a Variable. The information stored inside an object is called as a value. Of course the machine itself typically has no idea how to interpret the information it contains, but the program certainly needs to know. For this reason a variable has a specific type. And it’s this type that constrains the use of that variable, such that only operations appropriate to the type may be performed. The following is the syantax. [c]var variable_list : type;[/c]

Functions

Functions can be defined as a partitioned blocks of code in a program, which can be called any number of times during single execution of a program. Functions reduces the memory and complexity of the program. The following is the syntax. [c]function name(argument(s): type1; argument(s): type2; ...): function_type;[/c]

Objects

In any object oriented programming language coding will be made up with classes and object, As every one know that object is nothing but an entity that have state, behavior.

shape Example

The following is an example which describes how code will be executed in the pascal. Save the following code with the name Splesson as Splesson.pas. [c] Program Splesson; uses crt; begin writeln('Welcome To SPlessons'); (*Stop Thinking Start Coding*) end. [/c] In the above program Splesson is the name of a program, crt includes to the code before compilation. The program code will start with begin and ends with end. The writeln function is used to give the input. In the code comments will be written in between (*comments*) that does not take any memory. The following is the structure of the code. Output:Now compile the code result will be as follows. [c]Welcome To SPlessons[/c]

Summary

shape Key Points

  • In the code comment does not occupy any memory.
  • The pascal is not a case sensitive language.
  • By using writeln user can give an input to display.