Anda di halaman 1dari 54

Charlyn A.

Malimata

At the end of this lesson, you should be able to: 1. Define program and programming 2. Give the meaning of algorithm, pseudocode and flowchart. 3. Enumerate the advantages of making an algorithm, pseudocode and flowchart. 4. Design algorithms and pseudocodes. 5. Name the flowcharting symbols.

7. 8.

9.

Draw the flowcharts. Follow the guidelines in creating a flowchart. Develop critical, logical and analytical thinking in preparing for program writing.

Programming

Is the process of giving instruction to a computer


Programs

Are the instructions given to the computer to arrive at a certain result.

Logic formulations and problem-solving are the fundamentals of programming. It requires an intricate process of critical and analytical thinking combined with precision and keenness to details. The planning stage is very important because it serves as the backbone of any program.

NOTE: A GOOD PROGRAMMER IS A GOOD PLANNER

logical procedure or set of steps to be followed to arrive at a solution to a problem. An algorithm is the breaking down of a problem into simple steps in order to find the right answer.

Recipe in a cookbook a complicated dish is broken down into simple cooking instructions.
Choreography of a dance a difficult dance is broken down into a succession of basic steps Word problem in Math a complex problem in Math is broken down into parts to arrive at a solution.

An

algorithm in English statements in an outline form. This is used to conceptualize the flow of the program before encoding it in a programming language.

Pseudocode for Making Soap


Step Step Step Step Step Step Step Step 1: 2: 3: 4: 5: 6: 7: 8: Prepare your workspace Cut and weight the soap base. Melt the soap base. Add the fragrance or essentials oil Add color to the melted soap Stir the melted soap Pour the soap into the mold Unmold the soap

Pseudocode for Taking a special quiz


Step 1: Talk to the teacher. Tell her your concern Step 2: Give her the excuse letter Step 3: Ask politely for a schedule to have a quiz Step 4: If you are free on the given schedule, tell her you will be there to take the quiz. Step 5: If the schedule will be conflicting to another special quiz ask for another time and date until the schedule is finalized. Step 6: Go on the scheduled date and time.

Note: Pseudocodes cannot be executed on a real computer

The graphical representation of an algorithm. Flowchart is the pictorial description of sequenced activities and logic to be performed by the computer for carrying out data processing. It uses special symbols which represent a specific function.

Flowcharts are used by programmers before the actual start of any programming activity. Flowchart is otherwise known as Data Flow Diagram Flowcharts are used by programmers before the actual start of any programming activity. Flowchart is otherwise known as Data Flow Diagram Flowchart is the so called BLUE PRINT of a program.

TERMINAL - Represents the beginning and the end of the program. It contains the words Begin or Start and End or Stop.
PROCESS OR ACTION -Represents a step or an instruction such as comparison or arithmetic operations. Ex: Gather all materials in a box; Add 5 and 7 INPUT OR OUTPUT - Represents the step wherein information such as letters and numbers are entered byt he user or produced by the process. Ex: Input 3 numbers; Get A, B, C;

Print A

ARROW OR FLOW DIRECTION INDICATOR Indicates the flow of direction or the next activity.
DECISION Denotes a decision to be made. It involves 2 courses of action that is answered by either yes/true or no/false wherein one has to chosen. The symbol represents the if..then{, and the for .. Next statements PREPARATION Represents the process that will change the direction of initialization of any value or the execution of a variable.

PREDEFINED PROCESS OR SUBROUTINE Indicates a submodule or subflowchart embedded within a larger process. It can be described in a detail in a separate flowchart.
ON-PAGE CONNECTORS Indicates that the process is continued where the matching on page connector is placed (either on the same page or at a different page)

BEGIN

Give time, effort and commitment Exercise daily

Have a balanced diet


Sleep 8 hours a day

Take vitamins

Fit and healthy body

END

BEGIN

Type Internet username and password

Correct username and password


Yes
Access the Internet

No END

Create a flowchart for the following situations/problems


Flowchart to test printer Flowchart to get the product of 2 numbers Flowchart to print the area of a circle

1.
2. 3. 4.

The flow of the program is easily

understood. It determines the validity of the processes involved in the program. Debugging or correcting of errors becomes less complicated. It produces effective program documentation.

1.

Determine the following:


Data to be entered Information to be produced The way the data will be entered The point when data will be given The point when information will be produced

1.
2. 3.

There should be only be one start/begin and stop/end processes. Concentrate on the logic of the program. Choose only the important steps. No need to represent all the steps in the flowchart.

2 classifications of programming language. These pertains to the ways on how the program are written. High level programming resembles human language and corresponds to several machine language instructions Low level programming or machine language, describes exactly the procedures to be carried out by the computers central processing unit

High level Programming language includes :

1.

2.
3. 4.

5.
6. 7.

Visual Basic Java Visual C++ BASIC Pascal COBOL FORTRAN

Okay now, start getting busy by doing your first exercise for this module.

Plant and produce carrots Charter change (with decision box) Get the area of a rectangle Input 2 numbers and print the larger number Get the quotient of 2 numbers and print the quotient if it is greater than 5 Compute and print for the average of 3 numbers

A program handles different data to be processed by the computer. These data are classified into different types: Numeric data
Integer - whole Float or Double numbers with decimal

Alphanumeric Data
Number numbers that cannot be used for mathematical operations

Character a single letter or a special character String a combination of characters


Date and time Logical Data

allocates a portion of the memory depending on the type of data a variables holds.

variables stores data, It

It must begin with a letter or an alphabet and may be followed by combinations of alphanumeric characters. The name of the variables should be indicative of the value it holds. Avoid using confusing letters or numbers such as zero and the letter O. Use underscore in replacement of a space.

Lessen the number of characters of your variable. The shorter the variable, the better and more efficient the program will be In most cases, uppercase and lowercase letters are read differently A and a may hold different data

Constants are values that do not change during the execution of the program.

Examples:
Pi = 3.1416 X=100

Classifications of Operators
Arithmetic Operators
Addition Subtraction Multiplication

Division Exponentiation Modulus Negation Ex: 5+(4*2/2) 3 =6

Relational Operators Greater than >


Less than < Equal to = Not equal to <> Greater than or equal to >= Less than or equal to <=

Logical Operators
AND OR NOT

Conditions for the logical functions

Input 2 whole numbers. Compute and print the sum of the 2 numbers

When a problem involves the 3 Types of operators, the following order should be followed. Evaluation of different types of operators
The hierarchy is as follows:
1st Arithmetic operators 2nd Comparison operators
3rd logical operators

Evaluation of different types of logical operators


The hierarchy is as follows:
1st NOT 2nd AND
3rd OR Ex: 5*5+10/5 >40 AND 8<10 OR 7<4

Input 5 numbers. Find the sum, difference and product of the number. Print the answer Convert a number in degree Fahrenheit (0F) to Celsius (C)
A rectangular table has a length of 60.5 inches and a width of 20.5 inches. Find and print the perimeter.

Conditional statements is one of the vital components in programming. It enables a program to respond in a different manner every time a program is executed depending on the data entered. The commonly used conditional statements are:
If statement If ...then.. Else statements Select case statements

This is used to evaluate a condition or check a value as true or false. If the condition is not met, the succeeding statements or set of statements will executed. Syntax If condition Statement End if

Input a color. If the color is blue, display the message The color is blue. Algorithm:

String color Begin Input color If color= blue Print The color is blue End If End

Input a score. If the is 100, display the message Excellent

This is used to evaluate a condition or check a value as true or false. If the condition is not met, the statement or set of statements after will be executed Syntax:
If condition then Statement 1 Else Statement 2 End if

If condition then Statement(s) Else if condition 1 then Statement(s) Else if condition 2 then Statement(s) Else Statement(s)

Input a grade. If the grade is greater than or equal to 75, display the message You passed the subject, otherwise display Study hard Input 2 prices and get the total. If the total is more than P500, get 5% of the total, if the total is more than P500 but less than or equal to P1000, get 10% of the total, but if the total is greater than P1000, get 15% of the total. Display the discounted price.

The case statement is similar to the use of the If... Then .. Else statement. It is used when a variable is compared to different values or expressions. Syntax Select Case test expression Case expressionlist1 Statement Block1 Case expressionlist2 Statement Block2 End Select

Conduct Grade Equivalent 1 Excellent 2 Very Good 3 Good 4 Satisfactory 5 Needs Improvement Input a conduct grade and display the equivalent rating

Okay now, start getting busy by doing your first exercise for this module.

Anda mungkin juga menyukai