Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 13

ICT 101

General Programming Knowledge


An algorithm is a step by step i22nstructions that accomplish a task.
Syntax is the set of rules that you must follow to use the language.
Pseudocode is a tool programmers use to help them plan an algorithm.
An Expression is an algebraic representation that evaluates to a value.
Variable is an identifier whose value may not remain the same during
program execution.
Operators are symbols that indicate the type of mathematical
operations will be performed on the data or values of the variable.
Keywords also known as reserve word is a word with special meaning in
any given programming language
Statements is a line of code or simply an instruction that can be
executed in a program.
Computer programming is the process of creating a computer
program.
4/15/2014 2 Property of Projectcorp Nigeria
Examples of Operators
Arithmetic operators: +, -, *, /, \, ^, Mod
Relational Operators: =, > , < , >=, <=, <>
Logical Operators: AND, OR, NOT
String Operators: +


4/15/2014 3 Property of Projectcorp Nigeria
ORDER OF OPERATION
This is the order (order of precedence) in which operators are used in an expression.

For instance on QBASIC:
Parenthesis ()
Exponents (and Roots) ^
Multiplication and Division *, /
Addition and Subtraction +, -
[PEMDAS]
Alternatively:

Brackets ()
Exponentiation ^
Division and Multiplication /, *
Addition and Subtraction +, -
[BEDMAS]

4/15/2014 4 Property of Projectcorp Nigeria
Flowchart
A flowchart is a diagramatic representation of an
algorithm.
There are 2 types of the flowchart
1. Program flowchart
2. System flowchart

4/15/2014 5 Property of Projectcorp Nigeria
Program Flowchart Symbols


Symbols Meaning


Input/ Output
Process


Decision


Start/ Stop



Direction Arrows
On Page Connector
Off Page Connector
4/15/2014 6 Property of Projectcorp Nigeria
Expression
An Expression is an algebraic representation that
evaluates to a value.
Point to note about expression is that for every statistical, mathematical
formula, algebra or any other engineering formula must be converted into
QBASIC expression and interpretation before the result is shown at the output.
EG. Is the same as V = 4/3 * (PI * R ^ 3)

V = r
2
h Is the same as V = P * r ^ 2 * h

Is the same as I = (P * T * R)/100

4/15/2014 7 Property of Projectcorp Nigeria
Variables
Variable is an identifier whose value may not remain the same during
program execution.
Types of variable
a) String variable : String variable stores string data (i.e. quotation
statements) with a string variable name declare on that same line
whereby mathematical and logical operations cannot be done on it as
directed by the declaration symbols of dollar sign ($). E. G. Okeke$

b) Numeric variable : A numeric variable stores number data
inside it variable name that mathematical and logical operations can
easily be done on it as directed by its declaration symbols typed. ADA,
Ada%, Ada&, Ada!, Ada#

4/15/2014 8 Property of Projectcorp Nigeria
Rules for Naming a Variable
1. Variable names may have up to 40 characters in length typed
together without space.
2. Variable names can have alphabets, numbers and
alphanumeric on line numbers.
3. Variable name must begin with a letter
4. Variable names cannot begin with fn or Fn alphabets for
example, fnames$, fnum, etc. It is because fn causes the to
calculate frequency number of statistic data. Dont use it as a
variable name.
5. Variable names cannot be served words.
6. Variable names may be ended with type declaration characters
like $, %, &, !, and #
4/15/2014 9 Property of Projectcorp Nigeria
Keywords
Keywords also known as reserve word is a word with
special meaning in any given programming language












INPUT USE SYNTAX
PRINT Output PRINT N
CLS Clears the Screen CLS
END Terminates the Program END
IF Conditional statement IF (condition) THEN
ELSE
ENDIF
GOTO Jump to another part of the
program
GOTO Line Number
FOR loop FOR n = i TO j STEP k

NEXT n
4/15/2014 10 Property of Projectcorp Nigeria
Keywords cntd.












INPUT USE SYNTAX
DO Loop DO expression
.
LOOP
WHILE Loop WHILE expression

WEND
DIM Declaration DIM
CONST Declaration of
Numeric Constant
CONST A = 5 etc.
SELECT Control flow
statement
SELECT CASE expression
CASE

CASE ELSE

END SELECT
4/15/2014 11 Property of Projectcorp Nigeria
Sample Programs
Program to print the age of
someone
CLS
AGE = 11
PRINT I am; AGE; years Old.
AGE = 25
PRINT But I will grow and soon will be; AGE
END

Program to print the area of a
triangle
CLS
INPUT b, h
A = *b*h
PRINT The Area of the triangle is ; A
END
Program to print numbers
from 1 to 20
FOR i = 1 TO 20
PRINT i;
NEXT I
END
4/15/2014 12 Property of Projectcorp Nigeria




THE END
4/15/2014 Property of Projectcorp Nigeria 13

You might also like