Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language.

Slides:



Advertisements
Similar presentations
RAPTOR Syntax and Semantics By Lt Col Schorsch
Advertisements

Programming Paradigms and languages
Objectives Understand the software development lifecycle Perform calculations Use decision structures Perform data validation Use logical operators Use.
Modular Programming Splitting your program into functions and procedures.
Programming TBE 540 Farah Fisher. Objectives After viewing this presentation, the learner will be able to… Given a task, create pseudocode Given pseudocode,
DCT 1123 Problem Solving & Algorithms
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
High Level Programming Language Constructs Higher Computing Unit 2 – Software Development.
Working with Numbers in Alice - Converting to integers and to strings - Rounding numbers. - Truncating Numbers Samantha Huerta under the direction of Professor.
Mr C Johnston ICT Teacher BTEC IT Unit 06 - Lesson 05 Learning To Program.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
19/10/20151 Data Structures Arrays. 219/10/2015 Learning Objectives Explain initialising arrays and reading data into arrays. Design and write routine/s.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
I Power Int 2 Computing Software Development High Level Language Constructs.
Input Textboxes Input Boxes Different than textboxes Good for small amount of input (form full of textboxes is not nice) X = Inputbox(“prompt message”,
Software Development Topic 3 High Level Language Constructs.
CS285 Visual Basic 2 Department of Computing UniS 1 Statements in Visual Basic A statement is the fundamental syntactical element of a program smallest.
Chapter 2 Pseudocode. Objectives To introduce common words, keywords and meaningful names when writing pseudocode To define the three basic control structures.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Visual Basic Programming
Higher Grade Computing Studies 3. High Level Language Constructs Higher Computing Software Development S. McCrossan 1 Simple Data Types Integer: An integer.
Review, Pseudocode, Flow Charting, and Storyboarding.
22/11/ Selection If selection construct.
I Power Higher Computing Software Development High Level Language Constructs.
Top-down approach / Stepwise Refinement & Procedures & Functions.
31/01/ Selection If selection construct.
Higher Computing Software Development -So Far- 5/10/10.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Visual Basic Declaring Variables Dim x as Integer = 0 In the statement above, x is being declared as an Integer (whole number) and is initialised.
Selection Using IF THEN ELSE CASE Introducing Loops.
Algorithms and Pseudocode CS Principles Lesson Developed for CS4 Alabama Project Jim Morse.
7 - Programming 7J, K, L, M, N, O – Handling Data.
Visual Basic Fundamental Concepts
Unit 2 Technology Systems
CST 1101 Problem Solving Using Computers
3.1 Fundamentals of algorithms
COMPUTATIONAL CONSTRUCTS
Chapter 4 The If…Then Statement
Introducing Instructions
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
Visual Basic 6 (VB6) Data Types, And Operators
Programming Mehdi Bukhari.
The Selection Structure
Introduction To Flowcharting
Starter Question In your jotter write the pseudocode to take in two numbers, add them together then display the answer. Declare variables RECEIVE firstNumber.
User-Defined Functions
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
ALGORITHMS AND FLOWCHARTS
Chapter 10 Programming Fundamentals with JavaScript
Visual Basic..
CIS16 Application Development and Programming using Visual Basic.net
Algorithm Discovery and Design
ALGORITHMS AND FLOWCHARTS
If selection construct
Loops CIS 40 – Introduction to Programming in Python
Coding Concepts (Basics)
` Structured Programming & Flowchart
If selection construct
CS285 Introduction - Visual Basic
Introduction to Problem Solving and Control Statements
Text / Serial / Sequential Files
Flow of Control.
The structure of programming
The structure of programming
Thinking procedurally
10.3 Procedures Function Procedures 07/06/2019.
Introduction to Computer Programming IT-104
COMPUTING.
Presentation transcript:

Language Constructs Construct means to build or put together. Language constructs refers to those parts which make up a high level programming language. Features: String Operations Formatting input/output Control Structure (Sequence, repetition and selection) Data Storage (Local and Global variables, scope) Data Types (Real, Integer, boolean and one-dimensional arrays) Data flow (parameter passing)

String Operations (Concatenations and substrings) String operations can process string data. String operations include: Concatenations Sub-String Concatenation Concatenations is joining two strings. Two strings in and one string out. Example: PRINT “House” & “boat” Result: Houseboat

Need to know coding for exam Sub-String Selecting parts of string. VB uses Mid$ to extract a substring from a string. Example 1: “Hello higher Class” – Input string Mid$(string_in, 1, 1) Result: “H” Example 2: “I made him an offer he could not refuse” Mid$(string_in, 3, 8) “Made him” – starting at position 3 and counting 8 characters Need to know coding for exam

Formatting Input/output The way the program displays the data on the screen when inputting and outputting. Input Methods for VB Input box Text box Output Methods for VB Message box Picture box List box Tab() function can be used to create tabs in the output program.

Three basic control constructs used to define the order in which the instructions in a program are executed. These control constructs are found in all classifications of programming languages to control the flow of execution of the program code. Control Structured programming is based on three constructs: sequence selection repetition Sequence Order in which you give instructions to the computer. In sequence, one instruction is executed after another. The purpose of sequence is to ensure that instructions given to the computer are executed in the correct order.

Example Algorithm to add two numbers Ask user for first number Take in first name Ask user for second number Take in second number Add two numbers to find total Display total This would work only if the steps are followed. What would happen if this was used?

Selection Based on one or more condition, used together with a control structure such as IF or CASE. Conditions have values, they are either true or false. The purpose of selection is to allow a choice to be made in a program. Common control structures: If Mark >= 50 THEN Picdisplay.print “Pass” Else Picdisplay.print “Fail” End if Select Case Mark Case Mark >= 50 Picdisplay.print “Pass” Case Mark < 49 Picdisplay.print “Fail” End Select

Control Structured programming is based on three constructs: sequence selection repetition Repetition Involves using loops. Loops may be either conditional or Unconditional (Fixed) The purpose of repetition is to allows statements in a program to be repeated as many times as is necessary.  

Types of Loops Unconditional Loops (Fixed Loops) Repeat a set of program statements for predetermined number of times. Fixed loops are controlled by a variable called a loop counter. Example: FOR counter equal starts number TO finish number Do something NEXT

Repeats instructions until a condition is satisfied. Advantage Conditional Loop Repeats instructions until a condition is satisfied. Advantage Amount of data to be processed need not be known in advance A mathematical calculation can continue until answered Example Do mark1 = InputBox("Please enter mark 1") If mark1 > 10 Or mark1 < 0 Then MsgBox ("Please enter a mark between 1 and 10") End If Loop Until mark1 >= 0 And mark1 <= 10

42 Mark Data Storage Variables Data is stored in a computers memory in storage locations. Each storage location in the computers memory has a unique address. By using variable names a programmer can store, retrieve and handle data without knowing what the data will be. Types of variables Local Global Mark Dim Mark as Integer 42

Global Variables Can be referred to from anywhere in a program. Can be changed by any subprogram in the program. Modern programming practice recommends against the excessive use of global variables. They can lead to poor program structure, and tend to clog up the available name space. Local Variables Only exists within the subprogram in which it is declared. Will not be recognised by any other subprogram. Scope of variables The variable the sub program is used in. There is no need to worry about having the similar variable names when using different sub programs, since they cannot have any effect outside their scope.

Data Type String – may include letters, digits and punctuations. Integer – may consist of whole numbers Single/Real – may consist of whole number and real numbers (fractional) Boolean – may have two values, true or false.

Structured Data Types Related data items can be stored together using arrays. A data structure is a way of storing data in a computer in an organised way. One of the simplest data structures used in computer programming is called an array and is an example of a static data structure because it is of a fixed size within memory as defined within the structure of the program. Array A set of data items of the same type grouped together using a single variable name. Allows program to be more reliable and efficient. Example Wanted a program to take in 20 names and 20 test marks. Without an array you would need to declare 20 variables for name and 20 variables for mark.

Data Flow The movement of data between subprograms is implemented by using parameters. IN/OUT parameters Variables that are changed or updated IN parameters Variables that only pass data into a subprogram. OUT parameters Variables which only pass data out of subprogram. Parameters Information about a data item being supplied to a subprogram (Function or procedure) when called into use. When the sub-program is used this is known as parameter passing.

Parameters can be passed by either value or reference. Deciding which method to use depends on whether the parameter is going into or in/out of a procedure. By Value When a parameter is passed into a procedure When a parameter is passed by value into a subroutine, an exact copy of the current value of the variable is used. The value does not change. Allows one-way transfer between the main program and the subroutines or functions.

By Reference When a parameter is passed into a procedure, updated and passed back out again. Two-way data transfer between the main program and the subroutine. **Problem Arrays are always passed byref when using visual basic programming.

Importance of Data flow It is necessary to describe the data flow in a program in order to work out how the parameters should be passed between the main program and any subprograms.