PASCAL PROGRAMMING PROCEDURE IN PASCAL While coding, the need to reuse a part of the code might arise. It is not a good practice to copy this part again within the program. Instead, PASCAL has components, that is subprograms called procedures and functions for this purpose. These two components are make the program easier to write, debug and enhances readability. A procedure is a block of code which only runs when it is called. You can pass data, known as parameters, into a procedure. Procedures are used to perform certain actions. Why use procedures? To reuse code: define the code once, and use it many times. Procedures are subprograms that can return a single value or a group of results. Procedures have a set of parameters, value or variable. Value parameters are those which are only passed to the procedure, because otherwise the procedure would not be able to do the task it is said to. Value parameters do not change after the execution of procedures. They are given in the pa...
Posts
- Get link
- X
- Other Apps
By
Theophilus Ajala
on
PASCAL PROGRAMMING ARRAY IN PASCAL: To learn array, we need to first learn Subrange datatype. Subrange type A Subrange type defines a subset of the values of a particular type. Subrange helps to create a given boundary and it can be of integer, char. You can only use values within the specified range. If you assign value outside the give range, it will generate error. Syntax: type variableName = startValue..endValue var newVariableName : variableName //you create a new variable from the subrange type TIP: Start with the type keyword. to specify the startValue and endValue, you add two dots in between them. Program exercises implementing subrange type in Pascal programming Lab1 //define range of test scores and initialize program lab1; type score = 0..40; //number ranging from 0 to 40 var s1 : score; s2 : score; begin ...
- Get link
- X
- Other Apps
By
Theophilus Ajala
on
PASCAL PROGRAMMING LOOP STATEMENT / STRUCTURE Loop in Pascal performs repetitive tasks. For loop While loop Repeat until loop Program exercises implementing for-loop in Pascal programming For loop executes your program a specific number of times. Syntax: for variableName := startValue to endValue do begin //statements end; Lab1 //display numbers from 1 to 5 program lab1; var xcount : integer; begin for xcount := 1 to 5 do begin writeln (xcount); end; end. Lab2 //display DMACTUTOR five times program lab2; var xcount : integer; begin for xcount := 1 to 5 do begin writeln ('DMACTUTOR'); end; end. Lab3 //accept and display 5 different names from students program lab3; var xcount : integer; fullname : string; begin f...
- Get link
- X
- Other Apps
By
Theophilus Ajala
on
FORTRAN UNIT 4 SELECTION STATEMENT Selection statement or selection construct or selection structures is also called conditional or decision statement. The purpose is to make your program select a result from an option or from a list of options, when a specified condition is met. 4.1 PROGRAMS LAB EXAMPLES 4.1.1 Simple If Statement In simple if statement, only a single condition is evaluated, the if-block is executed, if the condition is true. Syntax: if condtion then !statements end if 4.1.2 Lab 1 – program to test the age of a student, if he eligible to vote program lab1 !declare variable integer :: age !display user action and accept information print *, 'Enter your age' read*, age !test and display !test if age <18, show 'teenager…’ if (age <18) then pr...