+ All Categories
Home > Documents > Programming

Programming

Date post: 19-Nov-2014
Category:
Upload: sean-chia
View: 1,519 times
Download: 14 times
Share this document with a friend
Description:
Chapter 5 P
Popular Tags:
33
Action 1 Action 2 False True Condition Action 1 Action 2 False True Condition
Transcript
Page 1: Programming

Action 1 Action 2

FalseTrue Condition

Action 1 Action 2

FalseTrue Condition

Page 2: Programming

DEFINITION

CONTROL STRUCTURE

DATATYPES

OPERATOR

CONSTANT & VARIABLE

TRANSLATOR

FLOW CHART

LEVEL & GENERATION

DEVELOPMENTPHASES

DEFINITION

CONTROL STRUCTURE

DATATYPES

OPERATOR

CONSTANT & VARIABLE

TRANSLATOR

FLOW CHART

LEVEL & GENERATION

DEVELOPMENTPHASES

PROGRAMMING

Page 3: Programming

FIRSTGENERATION

SECONDGENERATION

THIRDGENERATION

FOURTHGENERATION

FIFTHGENERATION

Page 4: Programming

FIRSTGENERATION

SECONDGENERATION

THIRDGENERATION

FOURTHGENERATION

FIFTHGENERATION

Machine Language

Assembly Language

High Level Language

Very High Level Language

Natural Language

BASICFORTRAN

CC++C#

JAVA

Page 5: Programming

1010 1001001 1001011101 1110111 0001101001 101010 1001101

MACHINE LANGUAGE

ASSEMBLY LANGUAGE

HIGH LEVEL LANGUAGE

Page 6: Programming

Get me computer sales in February.List me students from class 5S2.

SELECT SUM(total_price) FROM sales WHERE month = FebSELECT student FROM datafile WHERE class = 5S2

n = 1Do If class =“5S2” Then name[n] = NameFromFile End If n = n + 1Loop Until EOF(student)VERY HIGH LEVEL LANGUAGE

NATURAL LANGUAGE

HIGH LEVEL LANGUAGE

Page 7: Programming

1010 1001001 1001011101 1110111 000110

MACHINE LANGUAGE

ASSEMBLY LANGUAGE

HIGH LEVEL LANGUAGE

ASSEMBLER

INTERPRETER

COMPILER

IF MARKS > 50 THEN PRINT “LULUS”ELSE PRINT “GAGAL”END IF

Page 8: Programming

High LevelLanguage

MachineLanguageinto

are programs that translatehigh level language into machine language

Source Code(High Level Language)

Object Code(Machine Language)

10 Input “Number 1” ; x20 Input “Number” ; y30 z = x + y40 Print “Answer “ ; z

0010001 010010 00001000001001 001000 00100000010001 010010 00000010010011 010101 1010101

Page 9: Programming
Page 10: Programming

Constants difference Variables

Constants

retain their value

during the program execution.

characteristics

Variables

can change their value

during the program execution.

Const PI = 3.142Const GRAVITY = 9.8Const WAGE = 5.5

examplesDim Name as StringDim Score as IntegerDim Mark as Integer

Page 11: Programming

Data types Explanation

Integer(Number)

Integer data type contains any whole number value that does not have any frictional part.

Double(Number)

Double data type contains any decimal number value that has a fractional part.

String(Text)

String data type contains a sequence of character.

Boolean(Logical Value)

Boolean data type contains either a true or false value.

DateDate data type contains date and time value.

Page 12: Programming

Datatype Value Examples

Integer Whole numbers107 students-60 Celcius

Double Decimal numbersRM 123.453.5 kg

String Text informationAbu HassanJalan Bahagia

Boolean Logical values True or False

Date Date or time 12/5/2008

Variant Any datatypes N/A

Page 13: Programming

Integer Whole numbers -32,768 to 32,767

Long Whole numbers Approximately +/- 2.1E9

Byte Whole numbers 0 to 255

Single Decimal numbers -3.402823E38 to -1.401298E-45 for negative values and 1.401298E-45 to 3.402823E38 for positive values

Double Decimal numbers -1.79769313486232E308 to -4.94065645841247E-324 for negative values and 4.94065645841247E-324 to 1.79769313486232E308 for positive values

Currency Numbers with up to 15 digits left of the decimal and 4 digits right of the decimal

922,337,203,685,477.5808 to 922,337,203,685,477.5807

String Text information Up to 65,000 characters for fixed-length strings and up to 2 billion characters for dynamic strings

Boolean Logical values True or False

Date Date and time information

Jan 1st 100 to December 31st 9999

Variant Any of the preceding datatypes

N/A

Page 14: Programming

Assignment Operator

Mathematical Operator

Comparison Operator

Logical Operator

An operator is a symbol that causes VB to take an action

causes the left side operand to have right side value

to perform mathematical operations

to compare two value andreturn value whether true or false

to perform logical operations and return value whether true or false

Page 15: Programming

Age = 17

operand Asssignment operator

Page 16: Programming

Mathematical Operator

MeaningLogical

OperatorMeaning

+ Plus And And Operator

- Minus Or Or Operator

* Multiply Not Not Operator

/ Divide

Page 17: Programming

Comparison Operator

MeaningComparison

Operator

> Greater than >=

Greater Than or equal

< Less than <=Less

Than or equal

= Equal

<> Not Equal

Page 18: Programming

Action 1 Action 2

FalseTrue ConditionAction 1

Action 2

Action 3

Page 19: Programming

BEGINREAD Number Of ShareIF Number Of Share >= 1 THEN

Dividend = Number Of Share x 5 %PRINT Dividend

ELSEPRINT Error Message

END IFEND

END

BEGIN

READ Number of Share

False

True

Page 20: Programming

END

BEGIN

Average = (Number1 + Number2 + Number3)/3

Print Average

Get Number1Get Number2Get Number3

DeclarationDim Number1 as DoubleDim Number2 as DoubleDim Number3 as DoubleDim Average as Double

ProcessAverage = (Number1 + Number2 + Number3)/3

OutputtxtAverage.text = Average

InputNumber1 = txtNumber1.textNumber2 = txtNumber2.textNumber3 = txtNumber3.text

Page 21: Programming

Syarat Kemasukan SERATA

• Bahasa Arab = Lulus• Bilangan A > 4

If BahasaArab = Lulus And BilA > 4 Then DiTerima Masuk SerataElse Sila mohon ke sekolah lainEnd If

Logical Operator

Comparison Operator

Page 22: Programming
Page 23: Programming

parallelogram

rectangle

diamond

oval

arrow

Page 24: Programming

parallelogram

rectangle

diamond

oval

arrow

Page 25: Programming

parallelogram

rectangle

diamond

oval

arrow

FORMULA

READ / PRINT

IF – THEN - ELSEBEGIN / END

Page 26: Programming

Structured Approach is a computer programming technique in which the program is divided into modules like function or subroutine.

Object Oriented Approach is a computer programmingtechniques based on the concept of an “object” that combine both data and the function into a single unit.

Page 27: Programming

10 INPUT “X”

20 IF X = 2 THEN GOTO 60 ELSE GOTO 9030 PRINT “NUMBER ”;X 40 PRINT “PLEASE TRY AGAIN”50 END60 PRINT “NUMBER “;X70 PRINT “GOOD”90 END

Page 28: Programming

Structured Approach is a computer programming technique in which the program is divided into modules like function or subroutine.

GetInput (x, y)

z = Process (x, y)

DisplayResult (z)

Sub GetInput (x as integer) Input “Number 1” ; x Input “Number 2” ; yEnd Sub

Function Process (x as integer) as integer Process = x + yEnd Function

Sub DisplayResult (x as integer) Print x;”+”;y;”=“;zEnd Sub

Page 29: Programming

Object Oriented Approach is a computer programmingtechniques based on the concept of an “object” that combine both data and the function into a single unit.

Class aCircle Const PI = 3.142 Dim mRadius As Single Function Diameter() As Single Return 2 * mRadius End Function

Function Area() As Single Return PI * mRadius * mRadius End Function

Function Circumference() As Single Return 2 * PI * mRadius End FunctionEnd Class

Dim myCircle As New aCircle

myCircle.Radius = 10

Print myCircle.AreaPrint myCircle.DiameterPrint myCircle.Circumference

Page 30: Programming

1

2

3

4

Page 31: Programming

1

2

3

Page 32: Programming

main(){int radius;

cout << “Area of circle is “ << getArea(4);

cout << “Circumference of circle is” << getCircumference(4);}

double getArea(int r) { double area; area = 3.142 * r * r; return area;}

double getCircumference(int r) { double circumference; circumference = 2 * 3.142 * r ; return circumference;}

class Circle { private int radius; public void setRadius(int r) { radius = r; }

public double getArea() { double area; area = 3.142 * radius * radius; return area; } } class FindCircle { public static void main() {

Circle circle1; circle1.setRadius(4); cout << “Area of circle is” << circle1.getArea();}

data

function

class Circle { private int radius; public void setRadius(int r) { radius = r; }

public double getArea() { double area; area = 3.142 * radius * radius; return area; } }

object

Page 33: Programming

Recommended