Вы находитесь на странице: 1из 75

LESSON TEN

Introduction to Programming
Topics to be discussed

Programming languages
Program development life cycle
Algorithms and data structures
Flow charts
Web design using Hypertext Mark up language
(HTML)
Practical knowledge of BASIC and HTML programming
languages
OBJECTIVES

By the end of the lesson, students should be able to:

Explain programming language


Identify the categories of programming languages
Describe the features of particular Programming
language
Explain common terminologies associated with
programming
OBJECTIVES

State the basic steps involved in the development of a


computer program
Explain the concepts of algorithm
Explain the concepts of flow chat
Explain the term HTML
State the basic structure for HTML tags
Explain and use basic HTML tags
Explain some best practices in website development.
OBJECTIVES

Create, format and insert text into tables using HTML


Create an ordered an unordered list
Insert images and hyperlinks
INTRODUCTION

This lesson is an introduction to computer


programming, the process of writing instructions that
direct the computer to carry out a specific task.
Basic concepts of computer programming include
problem statements, algorithms, coding, control
structures, testing, and documentation.
Additional lesson topics include characteristics of
computer programming languages and brief
descriptions of todays most popular programming
languages.
Programming
Languages
A programming language is a standardized
communication technique for expressing instructions to a
computer. Like human languages, each has its own
syntax and grammar.
Programming language enable a programmer to precisely
specify what data a computer will act upon, how these
data will be stored/transmitted, and precisely what actions
to take under various circumstances.

Programming
Languages
There are different types of programming languages
that can be used to create programs, but regardless of
what language you use, these instructions are
translated into machine language that can be
understood by computers.
We can therefore define a programming language as a
standardized communication technique for expressing
instructions to a computer.
Categories of
Programming
Languages
High level Programming language is a programming
language that is more user friendly, to some extent
platform independent, and abstract from low level
computer processor operations such as memory
accesses.
A programming statement may be translated into one or
several machine instructions by a compiler. Examples are
Lava, C, C++, Basic, and FORTRAN.
Categories of
Programming
Languages
Low level Assembly Language: Examples of Low
level Programming languages are Machine language
and Assembly language.
Assembly languages are similar to machine languages,
but they are much easier to program in because they
allow a programmer to substitute names for numbers.
Each assembly instruction is translated into one
machine instruction by an assembler program.
Programming
Language
Characteristics
Programming languages have characteristics that describe
how they work and provide information about the types of
computing task for which they are appropriate. For example,
C++ can be described as high level, object oriented,
complied language.
When you need to select a language to use for a program, it
is useful to understand some of the general characteristics of
programming language. Some of the general characteristics
of programming languages include: Procedural, Declarative,
Scripting language, and Low level, High level, Compiled,
Interpreted and Object oriented.
Procedural

Languages with procedural characteristics create


programs composed of a series of statements that tell
the computer how to perform the process for specific
task. Languages with procedural characteristics are
called procedural languages. For example, the BASIC
programming language has procedural characteristics.
Procedural languages are well suited for programs that
follow a step by step algorithm. Programs created
with procedural languages have a starting point and an
ending point.
Declarative

A declarative language lets a programmer write a program


by specifying a set of statement and rules that define the
conditions for resolving a problem.
Declarative languages are useful for programs that
manipulate ideas and concepts, rather than numbers. A
program created with a declarative language describes
what the problem is.
For example, the Prolog language has the declarative
characteristic.
Scripting Languages

A scripting language defines a task in the form of a


script. Scripts require a host application to run and
cannot be run as a standalone application.
For example, you use HTML tags to specify a scrip for
how to display a Web page. This script is interpreted by
a Web browser. The Web brewer is the host application
without it, the HRML script cannot run.
2

Low Level And High


Level
A low level language requires a programmer to write
instructions for the lowest level of computer system that
is, for specific hardware elements such as the
processor, and RAM locations.
A high level language allows a programmer to use
instructions that are more like human language.
For example, BASIC language is a high level
language.
Compiled, Interpreted
And Object-Oriented
A compiler translates a program written in a high level
language into low level instruction before the program
is executed.
When you use a compiled language, you must compile
your program to produce executable program code.
An interpreted language uses an interpreter instead of a
compiler to create code that the computer can execute.
An interpreted language uses an interpreter instead of a
compiler to create code that the computer can execute.
Program Development
Life Cycle

A computer program is a set of detailed, step by step


instructions that tell a computer how to solve a problem or
carry out a task. Programmers do not sit down and start
writing code right away when trying to make a computer
program. Instead, they follow an organized plan or
methodology that breaks the process into a series of tasks.
This organized plan or methodology is what termed program
development life cycle.
Program Development
Life Cycle

The program development life cycle involves the following


basic steps: Problem Definition/Problem statement and
Problem Analysis
Algorithm design and representation
Actual coding, Testing and debugging
Complete documentation and operator procedures ready for
implementation.
In order to understand the basic steps in the program
developmental life cycle, let us define a single problem that we
will solve step by step as we discuss the problem solving
methodologies.
Problem Definition

Problems that you might try to solve using a computer


often begin as questions. So a programmer is usually
given a task in the form of a problem.
Before a program can be designed to solve a particular
problem, the problem must be well and clearly defined
first in terms of its input and output requirements.
Computer programming requires us to define the
problem first, before we even try to create a solution.
Example
Create a program that will determine the number of times
a name occurs in a list.
Problem Analysis
This step involves breaking up the problem into smaller
and simpler sub problems.
Example Problem: Determine the number of times a
name occurs in a list.
Input to the Program: List of names, name to look for
Output of the Program: The number of times the name
occurs in a list.
Algorithm Design and
Representation
In computer programming, it is normally required to express
our solution in step by step manner. An algorithm is a
clear and unambiguous specification of the steps needed to
solve a problem. The algorithm may be in either: Human
language, Flow chart or Pseudocode
The human language can be English. Flow chart is a
graphical representation.
The pseudocode, which is cross between human language
and programming language
Now for our example problem, how do we express our
solution as an algorithm?
Algorithm Design and
Representation
Expressing our solution through Human language:
Get the list of names
Get the name to look for, lets call this key name
Compare the key name to each of the names in the list
If the key name is the same with a name in the list, add
1 to the count
If all the names have been compared, output the result.
Actual Coding

After constructing the algorithm, it is now possible to


create the source code.
Using the algorithm as basis, the source code can now
be written using the chosen programming language.
Coding is the process of using a computer language to
express an algorithm.
A person who codes or writes computer programs is
called a Computer Programmer.
Testing and
Debugging

A computer program must be tested to ensure that it


works correctly. Testing often consist of entering test
data to see if the program produces correct results.
As you are coding a program, you must test each
section of your code to make sure it works correctly.
This process is referred to as debugging because the
process gets the bugs out so they dont cause errors
when you use the program.

Program Documentation
As you are coding, you should also write documentation
as a permanent record that explains how your program
works.
Program documentation explains how a program work
and how to use it.
Features of Programming
languages
The features to be looked at include but are not limited to the
following:
Data types, Constants and variables, Expressions and
assignments, Operators and precedence
Input / Output statements, Built in functions, Sequential and
conditional execution
Looping constructs, Single dimensional arrays and Nested Loops
The features will be explained in terms of QBASIC, questions will
be limited to QBASIC.
Every programming language consist some basic elements of
features which are required to make a program.
QBASIC program

The elements required to construct a QBASIC program


consists of :
a set of characters, keywords,
constants, variables,
operators and expressions.
Data Types

Every variable used in the program has a data type.


The table below shows the different types of variables
available in QBASIC:
Data Types Suffix
Single precision !
Integer %
Double precision #
Long integer &
String $
Constants and
Variables
Variables enable your program to remember values from one
program statement to the next. When you ran a QBASIC
program, the statements of the program are stored in main
memory. The data for the program can also be stored in main
memory. The data for the program also can be stored in main
memory.
A variable in QBasic is a small amount of computer memory that
has been given a name.
A variable is like a small box that holds a value. The value in the
variable can change (that is why it is called a variable). A
constant in QBASIC is a variable whose value does not change
during the execution of a program.
Expressions and
assignment
An expression is a correct combination of numbers,
operators, parenthesis, and variables. When the
operation in the combination is arithmetic, it is called
arithmetic expression. Example: 32.128 19.6 + 3.2
When the operator in the combination is logical, it is
called logical expression. Example: FLOUR > = 4
AND SUGAR > = 2. Storing or entering information into
the computer is done by using the LET STATEMENT or
the assignment statement.
Example: LET AGE % = 30 or AGE % = 30
Operators and
precedence

Operators are symbols that indicate the type of operation


QBASIC has to perform on the data or on the values of
variables. There are four types of operators in QBASIC.
They are: Arithmetic Operators, Relational Operators,
Logical Operators and String Operators.
Operator Precedence answers the question, which operator
is done first?
Arithmetic operators have each been given a priority. When
there is a choice, do the highest priority operation first. The
priorities of operations are given in the table. The highest
priority is 1 and lowest is 4
Priority of Arithmetic
Operators
Operator Meaning Priority

^ Power 1
- Negation 2
* Multiply 3
/ Divide 3
+ Addition 4
subtraction 4
Input / Output Statement

In QBASIC the INPUT statement gets data from the


computer keyboard. In programming, output means
data that the program sends outside itself to some
device. For us, output mostly will go to the computer
monitor. QBASIC uses the INPUT statement to input
data from the keyboard into the program. The INPUT
statement is used to get data from the keyboard. It will:
Print a question mark ? to the screen.
Wait until the user has typed in a value and Get the
value when the user hits the enter and Put the value in
the variable. In QBASIC, the PRINT statement is use to
output data from the program to the screen.
Built in functions

A function in QBASIC is a readymade program or user


made (small) program which helps to perform a specific
task. QBASIC supports two types of functions: User
define function and Built- in function.
A user define function is created by a user whenever
the user needs to perform a certain task that cannot be
performed by using Built in functions. A built in
function is ready made programs that accept data
and return a value. The two commonly used built in
functions: String functions / manipulators (e.g LEN,
RIGHT $, MID $, etc.) and Mathematical functions
(ABS, INT, MOD etc.)
Sequential and
Conditional Execution
Control Statements are statements that control the
program statements. Without the control
statements, the flow of execution program
statement is sequential, i.e. from one statement to
the next. There are two types of control statements.
Decision Making / Conditional statement and Loop
Statements.
Decision making or conditional execution involves
two types of statements: If then else statement
and Select ..Case statement.
Sequential and
Conditional Execution
The if else statement is used to express
conditional expressions. If the given condition is
true then it will execute the statements;
otherwise it will execute the optional
statements.
The Select Case statement is a special multi
way decision maker that tests whether an
expression matches one of the numbers of
constant values, and executes accordingly.
Looping Constructs

Looping Statements involves: For Loop, While Loop, Do


Loop and Go to Loop (breaking statement).
The For Loop is the most commonly used statement in
QBASIC. This loop consists of three expressions. The
first expression is used to initialize the index value, the
second to check whether or not the loop is to be
continued again and the third to change the index value
for further iteration.
Looping Constructs

The While Loop is used when we are not certain that


the loop will be executed. The execution loops only
when the initial condition is true.
The Do Loop, is used when we want to execute first
before checking the condition.
The Go to statement is used to alter the program
execution sequence by transferring control to some
other part of the program.
Single dimensional
arrays
A list of quantities can be given one variable name
using only one subscript and such a variable is called a
single subscripted variable.
A single subscripted variable is also called as single
dimensional array or variable.
For example, a set of five numbers say (19, 17, 11, 3,
-5) can be represented in an array as x (5). Where x is
an array name and 5 is subscript of index.
Algorithms and Data
Structures
An algorithm is a set of steps for carrying out a task. An
algorithm is an abstract idea, but it can be written down
and it can be implemented. The algorithm is written down,
or expressed, as instructions in solving a problem. An
important characteristic of a correctly formulated algorithm
is that by carefully following the steps, you are guaranteed
to accomplish the task for which the algorithm was
designed.
An algorithm for a computer program is typically first
written in a format that is not specific to a particular
computer or programming language.
Algorithms and Data
Structures
The algorithm is translated into instructions written in a
computer programming language so the algorithm can
be implemented by a computer.
The concept of algorithm can be summarized as:
They are a sequence of steps
They are set of instructions (method) which if faithfully
followed will produce a solution to a given problem.
Techniques for Representing
Algorithm

You can express an algorithm in several different ways


including:
Structured English is a subset of the English language with a
limited selection of sentence structures that reflect
processing activities.
Psendocode is a notational system for algorithms that has
been described as a mixture of English and your favorite
programming language.
Flow Chart is a graphical representation of the way a
computer should progress from one instruction to the next
when it performs a task.
Algorithm Building
Blocks

All problems can be solved by employing any one of


the following building blocks or then combinations:
Sequences, Conditionals and Loops.
A sequence of instructions that are executed in the
precise order they are written in: Statement block 1,
Statement block 2 and Statement block 3.
Conditionals: Select between alternate courses of
action depending upon the evaluation of a condition.
Loops: Loop through a set of statements as long as a
condition is true.
Flow Chart

A flow chart is a graphical representation of the way a


computer should progress from one instruction to the
next when it performs a task.
Flow chart concept: Flow charting is one method of
pictorially representing a procedural (step by step)
solution to a problem before you actually start to write
the computer instructions required to produce the
desired result.
Factors to consider in
constructing
flowcharts
Think through the problem solution step-by-step.
Analyze the specifications in terms of: The required
input, The output desired and The operations and
procedures required to produce the output.
Clarify the problem by having a narrative definition
of the problem definition
Develop a flow chart showing the logic, steps, and
sequence of steps you want the computer to
execute in order to solve the problem.
Flow Chart Symbols

Flow chart symbols are graphic symbols used to specify


arithmetic operations and relational condition
Flow Chart Symbols
Key to Flow Chart Symbols

Start or end


Input or output

Decision



Calculation


Connector


Flow line

Terminologies Associated
with Programming
High level language: A computer language that allows
a programmer to write instructions using human like
language.
Machine Language / Code: A low level language
written in binary code that the computer can execute
directly. Source Code: Computer instructions written in
a high level language.
Class: In object oriented programming, a group with
specific characteristics, to which an object belongs.
Compiler: Software that translates the program written
in a high level language into low-level language.
Terminologies Associated
with Programming

Event driven language: A computer language


that helps programmers create programs that
continually check for, and respond to, program
events.
Debugging: The process of testing a section of
code and correcting errors.
Syntax: Specifications for the sequence and
punctuation of command words, parameters and
switches.
Terminologies Associated
with Programming
Syntax error: An error that results when an instruction
does not follow the syntax rules, or grammar, of the
programming language.
Run time error: An error that occurs when a computer
program is run. Coding: The process of using a
computer language to express an algorithm.
OOP: Object oriented languages, Programming
languages that focus on the manipulation of objects
rather than on the generation of procedure based
code.
Web design(HTML)

The Web provides opportunities for publishing tasks ranging
from a single page to an entire Web site. A single Web page
is simple to create and can publish useful information such
as your resume or a publicity flyer for your school.
Another use for a single Web page is to provide a list of
links to sites information on a particular topic. A Web site
includes a series of Web pages and has its own domain
name.
Business and organizations of all sizes create Web sites to
provide information to customers and to sell products.
Understanding the
term HTML
HTML is the language used to design Web Pages. It
stands for Hyper Text Markup Language. An HTML file
or document has a HTM or HTML file extension. Every
Web page is stored as an HTML document.
An HTML document contains special instructions that
tell a Web browser how to display the text, graphics and
background of a Web page. These instructions, called
HTML tags, are inserted into the text of the document.
Writing HTML document entails using tag correctly to
create your vision.
Basic Structure of
HTML document
A basic HTML document has two parts: The head and the body.
The head of the document specifies a little that appears on the
title bar of the Web browser when the Web page is displayed.
The body of the document contains informational text, graphics,
and links.
Every HTML document should begin with the tag < HTML> and
end with the tag < / HTML>.
The traditional way to create an HTML document is with a basic
text editor such as the Notepad program included with Microsoft
Windows. Simply type the HTML tags and the text for your Web
page, then save the file with an HTM extension or HTML
extension.
The basic structure of an HTML
document is

< html >


< head >
< title > < / title >
< / head >
< Body >
< / Body >
< / html >
Basic HTML Tags

HTML Tags are instructions embedded into a text


document. These special instructions tell a web browser
how to display the text, graphics and background of a
Web page. Each tag appears as letters / words / short
codes between angle brackets, < >. Some HTML tags
work in pairs. They are called Paired / Container Tags.
Normally come in pairs like < b > and < / b >.
The first tag, eg. < b > , is start tag, the second tag, e.g.
< / b >, is the end tag. Paired tags are used to flank text
to be affected eg. < i > In all < / i >. A start tag and an
end tag form are HTML element.
Basic HTML Tags

Some HTML tags do not have a corresponding end tag.


They are called Singular / Empty Tags. For example,
you only need a single < BR > tag to create a line
break.

Вам также может понравиться