+ All Categories
Home > Documents > PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or...

PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or...

Date post: 12-Jan-2016
Category:
Upload: sheena-sanders
View: 214 times
Download: 0 times
Share this document with a friend
Popular Tags:
45
PROGRAMMING LANGUAGES Prof. Lani Cantonjos
Transcript
Page 1: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

PROGRAMMING LANGUAGES

Prof. Lani Cantonjos

Page 2: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• PROGRAM - set of step-by-step instructions that tells or directs the computer what to do.

• PROGRAMMING LANGUAGE - Set of rules or instructions that tells the computer what to perform

Page 3: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

PROGRAM LIFE CYCLE

• I. IDENTIFYING THE PROBLEM

This is the first step. it involves determining the requirement of the program.

ex. you are the programmer and somebody seeks your services in creating a program, As the client gives the desired output requirements, you are to analyze the need to be able to come up with a suitable programming solution.

Page 4: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• 2. PLANNING THE SOLUTION -

There are two ways of planning the solution to a problem, they are: 1. draw a flowchart and 2) write a pseudo code.

Page 5: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• FLOWCHART - is a graphical representation of the step-by-step instruction to be done in a program while

• PSEUDO CODE - is listing down the set of instructions to be used in the program.

• note: this 2 approaches are not executable in a programming language; you are just planning the solution.

Page 6: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• 3. CODING THE PROGRAM - as you designed the solution the next step is to code the program with the use of a chosen programming language.

Page 7: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• note:• SYNTAX - Programming languages have their

own set of rules to follow.

• SYNTAX ERROR - Violation of the rule set by programming language used in a certain program will produce an error.

• MISSPELLING - One of the common causes of syntax error.

Page 8: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• 4. TESTING THE PROGRAM -

• After coding the program, it is important to test if it is running. If it runs properly, then it is free from syntax error.

Page 9: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

TESTING THE PROGRAM

• DESK CHECKING - In this phase the programmer just mentally traces or checks the logic of the program to make sure that its error free.

• TRANSLATION - In this phase the programming language uses a translator to ensure that the programmer did not violate any language rules by the chosen programming language. This program translates the program line by line to locate the syntax error.

Page 10: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• DEBUGGING - this means detecting, locating and correcting bugs. In programming, error or mistakes are called bugs. In debugging phase you run the program and use the dummy data or test data. Then, the programmer checks the flow of the program. If it is logic is error free and if it meets the requirements of the specified program.

Page 11: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• DOCUMENTATION- The programmer makes a detailed description on how the program was created. It contains a brief narrative process undergone by the program, from the identification of the problem, planning of the solution through flowcharting and pseudo code, coding of the program up to the testing results.

Page 12: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

LEVELS OF PROGRAMMING LANGUAGES

• 1. MACHINE LANGUAGE OR FIRST GENERATION PROGRAMMING LANGUAGE - This is considered to be the lowest level of programming language. The program is considered by 1s and 0s. We all know the 1s and 0s or binary number is the only language the computer understands.

Page 13: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• ASSEMBLY LANGUAGES OR SECOND GENERATION PROGRAMMING LANGUAGE -

This is also considered as low level language. However, programmers would find this language easier to use than machine language. Instead of using 1s and 0s, assembly language uses mnemonic codes.

Page 14: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• HIGH LEVEL LANGUAGE OR THIRD GENERATION PROGRAMMING LANGUAGE 3GL

• This language transformed programming in the early 1960s. it makes programming easier since the language is now written in English like manner. If assembler is used by assembly language, third generation languages used translator to convert the program into a machine language.

Page 15: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• VERY HIGH LEVEL LANGUAGES OR 4TH GENERATION LANGUAGES (4GL)

• Fourth generation languages (4GL) simplifies further the third level generation languages 3GL because there is a reduction in the number of instructional statements. 100 lines of instructions in 3GLs can be reduced to 5 to 20 lines of instructions in 4GLs

Page 16: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• NATURAL LANGUAGES

• These languages are considered to be that 5th generation languages. These programming languages are called natural languages because of their resemblance to English language.

Page 17: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

2nd Lecture

• PROCEDURAL AND NON PROCEDURAL LANGUAGES

• PROCEDURAL LANGUAGES – Programming languages which are considered procedural uses a series of instructions or statements which are sequential from the beginning to the end. This means that execution of instructions is line by line and it is terminated after the last instructions

Page 18: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Examples of Procedural Languages:

• BASIC (Beginner’s All-Purpose Symbolic Instruction Code)

• COBOL (Common Business Oriented Language)

• PASCAL

• FORTRAN (Formula Translator)

• C

• PL1 (Programming Language 1)

Page 19: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Non-Procedural Languages

• These programming languages are considered object-oriented programming languages. Statements are not executed line per line instead a series of instructions are executed as a whole when an event occurs.

Page 20: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Examples of Non-Procedural Languages

• VISUAL BASIC

• C++

• JAVA

• DELPHI

Page 21: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Flowcharting

• Flowchart is one of the processes used in designing or planning the solution to a problem. It is a graphical representation to the solution of a problem. It uses shapes to show instructions and arrow lines and heads to display the flow.

Page 22: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

SYMBOLS

• Oval – Terminal Symbol – Represents start and end of program

Page 23: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• Parallelogram – Input/Output – Indicates input and output

Page 24: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• Rectangle – Process – This represents processing of action, e.g. mathematical operator

Page 25: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• Diamond – Decision – Since computer only answer the question yes/no, this is used to represent logical test for the program.

Page 26: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• Hexagon – Initialization / Preparation – This is used to prepare memory for repetition of an action.

Page 27: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• Arrow Lines & Arrow Heads – Direction – This shows the flow of the program

Page 28: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• Annotation – This is used to describe action or variables

Page 29: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• Circle – On Page Connector – This is used to show connector or part of program to another part.

Page 30: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• Pentagon – Off-Page connector – This is used to connect part of a program to another part on the other page or paper.

Page 31: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Structure of a Flowchart

Page 32: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Problem No. 1

• Draw a flowchart that will display the sum of 2 entered integers

• Requirement of the Problem No. 1– Ask the user to enter 2 integers

– Process it with Sum

– Display Result

Page 33: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Answer

• A =

Represent

The 1st

Integer

• B =

Represent

The 2nd integer

ENTER A, B

SUM=A+B

DISPLAY SUM

END

Page 34: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Exercise # 1

• Draw a flowchart that will compute for the average of 3 input quizzes. Then display the result.

Requirement of Assignment No. 1

1.Ask the user to input 3 quiz scores

2.Get the average of the 3 quizzes. Average is getting the sum of 3 scores divided by 3.

3.Display result.

Page 35: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Assignment #2

• Draw a flowchart that will display “Access Granted” If the password entered is equal to “Computer” else will display Access denied. Explain the action inside the flowchart and write it inside the box.

• Requirement of Assignment #2

1.Ask the user to enter the password

2.Display “Access Granted” if the password entered is equal to “Computer”, on the false side display “Access Denied”.

Page 36: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

3rd lecture

• Use of Decision Symbol– One of the symbols used in flowcharting is the

decision symbol or the diamond. This symbol requires logical test that could be determined by using conditional statements or characters which are listed below. Through logical test, this symbol provides true answers, if the value evaluated by the decision symbol produces a “true” result or if it did not meet the value on the conditional statement it renders a “false” value.

Page 37: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Mathematical Notation Flowchart Notation Meaning

= = Equal

≠ ≠ Unequal

< < Less than

> > Greater than

≤ <= Less than or equal to

≥ >= More than or equal to

Page 38: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Equal

• The operator is used to compare two values for similarity. Syntax of the operator is:

– Is value 1=value2

Page 39: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

• If value 1 and value 2 have the same value then they will move to the true side of the decision symbol. If both values hold different values, on the decision symbol it will move to the false side. This is illustrated as:

Page 40: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

START

ENTER V1 and V2

V1 – represents value 1V2 – represents value 2

IS V1=V2

PROCESS FOR TRUE VALUE

PROCESS FOR FALSE VALUE

STOP

YES NO

Page 41: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

ANSWER TO ASSIGNMENT #1START

ENTER PASSWORD

IS PASSWORD

= COMPUTER

DISPLAY ACCESS

DISPLAY ACCESS

STOP

YESNO

Page 42: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

NOT EQUAL

• The operator is used to compare if the two values are not equal or show inequality. This is the inverse of equal operator.

• Syntax of the operator is:

– Is Value1 <> Value2

Page 43: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Exercise #1

• Draw a flowchart that will compare if 2 values are not equal (Use variables). If value1 and value2 are not equal or not alike, the flow of the flowchart will move to the “true” side of the decision symbol. If both values hold the same value then it will move or flow to the “false” side.

Page 44: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Quiz #2

• Draw a flowchart that will display “A Foreigner” if the country entered is not equal to Philippines else flowchart should display “A Filipino”. Explain the action inside the flowchart.

• Requirement of Program:– Ask user to enter country.– Use decision symbol and use logical test: if country <> Philippines– True side of the symbol is, country is not equal to Philippines display

“A Foreigner”– False side of the symbol is, if country is equal to Philippines then

display “A Filipino”.– End of Program.

Page 45: PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.

Assignment #2

• Draw a flowchart that will display the higher number between two entered integers.– REQUIREMENT OF THE PROGRAM

• ASK USER TO ENTER TWO NUMBERS

• USE DECISION SYMBOL TO DETERMINE WHICH HAS THE HIGHER INTEGER.

– A. if N1 holds a value that is greater or higher than N2


Recommended