Introducing 

Prezi AI.

Your new presentation assistant.

Refine, enhance, and tailor your content, source relevant images, and edit visuals quicker than ever before.

Loading…
Transcript

Global

Local/Global

Global variables can be used anywhere in the program

We can declare a global variable using the global key word

This means that they are accessible from both the main body and the sub programs

Functions

Functions

✳✱*

Variables can be local or global

Any variable used within a sub program is local and can only be called within itself

VERY similar, but functions ALWAYS return a value back to be used in the main program

This means you can use the same variable name as other local variables without any issues

Functions always take at least one parameter

When calling a function we assign it to a variable - otherwise the value returned is lost!

Task

Write a function takes two strings and joins them together with a space in between them.

Call your function and print out the result in the main program

Functions and procedures

With a parameter

Procedures are blocks of code stored under one name

Called by typing their name - sometimes we also pass an argument to them

Lesson Objectives

To know the difference between a function and a procedure

To know the advantages of using sub programs

To use sub programs to solve a problem

Revise, Recap, Review

3 commands used in SQL

2 data types and what they store

1 SQL statement to return all Jaguar 'make' cars from the table 'Cars'

Lesson 10 - Sub programs

Sub program

A mini program within your program

They SAVE TIME if we use repeated code in our program

Type the code out once and give it a name

When you want to use that block of code you just type the name

Task

Learn more about creating dynamic, engaging presentations with Prezi