You are on page 1of 24

What is a Computer?

- an electronic device capable of performing complex computations in a short time - a fast electronic calculating machine that accepts input information, processes it according to a list of internally stored instructions called a program, and produces the resultant output information. - A program is a set of instructions for a computer, telling it what to do or how to behave - Programming is the craft of implementing one or more interrelated abstract algorithms using a particular programming language to produce a concrete computer program. Components of a Computer Hardware – the physical equipment of a computer system, including the monitor, keyboard, central processing unit, and storage devices. Software – refers to one or more computer programs and data held in the storage of a computer for some purpose Hardware Concepts - Data representation: conversion of images, letters and sounds into electrical signals - Digital electronics: manipulation of “on” and “off” signals to perform complex tasks - A digital device works with discrete signals, such as 0 and 1. - An analog device works with continuous data. - As an analogy, a traditional light switch has two discrete states – on and off. A dimmer switch, on the other hand, has a rotating dial that controls a continuous range of brightness – from none (off) to full brightness. The first is therefore a digital device while the latter is an analog device. Digital Data Representation - The “0” and “1” are also known as bits or binary digits - A sequence of “0” and “1” could be written as 10011, this sequence may have significant value, for instance it may pertain to a certain character or number. How can a computer represent numbers using bits? - Numeric data like your age, salary, electricity bill are easily understood by humans. Then, how is it possible for a computer to show a number using only binary digits? - The computer uses the binary number system which uses only two digits: 0 and 1. There are no 2’s or 3’s. A series of 0’s and 1’s results in a particular number much in the same way we use the decimal number system. DIGITAL DATA REPRESENTATION This table shows how binary system works. Decimal ( Base 10 ) 0 1 2 3 4 5 6 7 9 Binary ( Base 2 ) 0000 0001 0010 0011 0100 0101 0110 0111 1001

If the box contains 0, the value is turned “off”’. However if the box contains 1, the value of that box is turned “on” and will be added to the sum. How can a computer represent words and letters using bits? Much like representing numerical data, bits can also be used to represent character data. It is synonymous to using Morse code using the dashes and dots to represent letters in the alphabet. In this case, computers makes use of 0 and 1 as a replacement to dashes and dots.

Example: STI has a corresponding binary value. S – 0101 0011 T – 0101 0100 I – 0100 1001 There are many ways on how the computer can represent characters and numbers. Some types of codes are: ASCII (American Standard Code for Information Interchange) • requires only seven bits for each character. EBCDIC (Extended Binary Coded Decimal Interchange Code) • is an alternative 8- bit code used by older IBM mainframe computers. UNICODE uses 16 bits providing codes for 65000 characters and becoming popular. Extended ASCII code makes use of a series of O’s and 1’s for it to symbolize the 256 characters (includes letters for uppercase and lowercase, number, and symbol). BIT BYTE PREFIX Kilo Mega Giga Tera An abbreviation of binary digit Other abbreviation for bit is the lowercase “b” A collection of bits (8 to be exact) Usually abbreviated as an uppercase “B” ABBREVIATION K M G T VALUE 210 220 230 240

How are bits stored and transferred from one point to another? - Since most computers are electronic devices, bits take the form of electrical pulses traveling over the circuits. All circuits, chips, and mechanical components forming a computer are designed to work with bits. The basic parts of the computer INPUT DEVICES are machines that generate input for the computer, such as keyboard and mouse. PROCESSOR or CPU (Central Processing Unit) is the central electronic chip that controls the processes in the computer. It determines the processing power of the computer. OUTPUT DEVICES are machines that display information from the computer, such as monitor, speaker, and printer. MEMORY is the part of the computer that stores applications, documents, and systems operating information. SOFTWARE CONCEPTS What is software? - Computer instructions or data - Anything that can be stored electronically - Computer programs, modules (support and data) working together providing computers with instructions and data for certain task (e.g word processing, internet browsing) Terminologies: COMPUTER PROGRAM (or “program”)- an organized list of instructions that, when executed, causes the computer to behave in the predetermined manner.

SUPPORT MODULE-an auxiliary set of instructions used in conjunction with the main software program DATA MODULE-contains data (not supplied by the user) necessary for the execution of certain task. DATA vs. SOFTWARE - Before, the term “software” is always associated to all non-hardware components of a computer. - However, modern definitions made it clear that all documents, spreadsheets and even downloaded materials from the net are now classified as data. Software Basics - Technically, the computer creates object code, which is the machine language representation of the source code, and the linker creates the executable code. - The linker combines program object code, object code from library routines and any other required system code into one addressable machine language file. Application Software vs. System Software Software are basically categorized into two: Application software and System software. Some people used the term “software” to describe either application or system software. Application software provides instructions to the computer depending on the use (application). The purpose of application software is to help automates common task (example: typing, accounting task, etc). System software help the computer carry out its basic operating function. Under this type of software includes device driver, operating system, and other utilities. What is SLDC? A common methodology for systems development in many organizations, featuring several phases that marks the progress of the system analysis and design effort. An outline of a process that helps develops successful information system. Is the process of developing information systems through investigation, analysis, design, implementation and maintenance. SDLC is also known as information system development or application development. Also known as System Development Life Cycle What is importance of SLDC? In order to create systems that are in good in design we must take into consideration that it must involve several phases. You cant just create it in just one big attempt. Furthermore, it would be very favorable for companies to have certain set of standardized steps that would serve as a guide in system development. What are the 5 phase of SDLC? SDLC involves several phases. Each phase plays an important role to create a good system. The said phases are: 1. Planning 2. Analysis 3. Design 4. Implementation 5. Maintenance Planning phase Planning is also known as project identification and selection. This phase is involves identification for the need or enhancement(s) of the current system being used. For larger companies that deal with complicated systems, it is vital that these requirements are properly identified so that the development of the system may not be delayed or stray from the original objective. “The first phase of the SDLC an organization’s total information system are identified, analyzed, prioritized, and arranged.”

Analysis phase This phase requires the analyst to thoroughly study the current procedures or system used to execute tasks in an organization. The main goal in this phase is to identify the requirements for a new system or simply change several aspects in the current working system. ”This phase studies the current system and produces proposed alternatives or replacements” Design phase During this phase, the developer of the system translates the result of the previous phase into actual design or specifications of the system. Development of the system involves covering the input and output screens to reports, databases, and computer process. Implementation Phase After the design phase, we must put the proposed system into the test. During this phase, implementing the system will include several steps: 1) Coding- creation of the actual program. 2) Testing- both programmer and analyst submits the system to various “quality testing” to discover if there any bugs within the system. 3) Installation- after coding and testing is done, the actual system must be installed and slowly or completely replaces the old system. Maintenance Phase With every phase being comleted, perhaps the maintenance phase would be the most prevalent phase of all. There are some bugs in the system which can’t be properly indentified without putting the system into actual use. The maintenance phase is used to make necessary patches to remove found errors. This is were the system is systematically repaired and improved based on errors or possible new requirements found. SOFTWARE DEVELOPMENT LIFE CYCLE Waterfall SDLC The waterfall SDLC suggests that prior to proceeding to next phase, the current phase should be finished first. But applying this strategy in the real world would be unfeasible since it would be impossible to modularize system development. Modified Waterfall and Iterative SDLC This version of the SDLC is more flexible compared to the traditional SDLC model. Since, nature of developing a system is unpredictable using this model will allow the developer to adjust to certain situations. (Example: unforeseen requirement or additional features that are highly needed in the system. The modified waterfall SDLC allows overlap between phases. The iterative SDLC allows phases to repeat, if necessary. Programming Cycle - Problem Definition - Problem Analysis o Input o Output - Algorithm Development o Process o Pseudocodes and Flowcharts - Coding and Debugging Algorithm - a step by step problem-solving procedure, especially an established, recursive computational procedure for solving a problem in a finite number of steps - finite sequence of steps for solving a logical or mathematical problem - a specific set of well-defined, simple mathematical and logical procedures that can be followed to solve a problem in a finite number of steps

Example

1. Baking of chocolate cake 2. Computing for average grade 3. Going from one location to another These characteristics will serve as guide or determiner to have good algorithms. 1. Specify each step or instruction exactly. There must be no ambiguity. The instructions must be clear. 2. There must be a finite number of steps. The algorithm must terminate. There must be a stopping point. 3. There must be an output. The algorithm must produce the correct result. Pseudocodes - generic way of describing an algorithm without use of any specific programming language syntax - it cannot be executed on a real computer, but it models and resembles real programming code, and is written at roughly the same level of detail Flowchart - a chart that contains symbols referring to computer operations, describing how the program performs - a graphic map of the path of control or data through the operations in a program or an information-handling system - symbols such as squares, diamonds, and ovals represent various operations - these symbols are connected by lines and arrows to indicate the flow of data or control from one point to another Flowchart Symbols Terminal Block Initialization Block Process Block Connector Input/Output Block Flow Lines Decision Block

Flow Lines - indicated by straight lines with arrows to show the direction of data flow - the arrowhead is sometimes not shown when the direction of flow is clear - used to connect blocks by exiting from one and entering another Terminal Block - ovals or rounded rectangles are used to indicate the start and the end of a module or program - an oval is labeled with the name of the module at the start - the end is indicated by the word end or stop for the top or Control Module - a start has no flow lines entering it and only one exiting it; an end or exit has one flow line entering but none exiting it

START

STOP
Initialization box - is used for declaring/initialing variables needed to solve a certain process. Take note: you can only use variables that are placed inside the initialization box

Declaration
• • Binding of an identifier to the information that relates to it. Set a variable name to be used.

Initialization
• To set a starting value of variable.

X=10 Y=25

Process Box – The rectangle indicates a processing block, for such, things as calculations, opening and closing files, and so forth. A processing block has one entrance and one exit.

X=Y+Z A = 18 B=A-2

Input/Output Box - The parallelogram indicates input to and output from the computer memory. An I/O block has one entrance and only one exit.

Display Decision Box – The diamond indicates a decision. It has one entrance and two and only two Enter X exits from the block. One exit is the action when the resultant is TRUE X and the other exit is the action when resultant is FALSE. CONVENTION
TRUE
T

FALSE
F

YES
Y

NO
N

T

Condition

F

Action when TRUE

Action when FALSE

Connectors – The connector block is used as a connection between two sections of a flowchart that is not adjacent or closely located to each other. Note: These connectors should be used as little as possible. They should be used to enhance readability. Overuse decreases readability and produces a cluttered effect.

A

START

A

START

Age = 18

Age = 0 Cyr = 2007 Byr = 1990

Flowchart Case Study: Create a flowchart having a variable that isAge = Age to your current age. initialized + 5 Your flowchart should be able to show your age 5 years from now

Flowchart Case Study: Create a flowchart having 3 variables. Two of the = Cyr - Byr used to initialize Age variables are the Birth Year and Current Year. Your variable is used to compute for the current age. Your flowchart should display the age value.

Display Age

Display Age

STOP

STOP

Create a flowchart that will increase the value of the number by 5 if it is greater than 10 and display the result; otherwise do nothing.

Create a flowchart that computes for the circumference of a circle. Assume that the value for radius is 7.23. Your flowchart should be able to show the value of the circumference. Additional facts: The pi value is 3.1416, which is constant and should never be changed. You can compute the circumference by using this formula 2Πr.

START

Circ = 0 Rad = 7.23 Pi = 3.1416

Circ= 2 * Pi * Rad

Display Circ

Start

x=0

STOP

Get x x=x+5 Display x Yes Stop
X> 10?

No

CONDITIONAL OPERATORS What is a Condition? Conditions are statements that result to a Boolean value. The Boolean value may either be a TRUE or FALSE, 0 or 1 value. Conditions are categorized into two: • • LOGICAL OPERATORS RELATIONAL OPERATORS

In programming, there are three basic logic operators that you could use for conditional statements. They are the following: LOGICAL OPERATORS: • AND • OR • NOT

The commonly used logical operators are AND and OR, while NOT is a logical operator that negates the result of the Boolean value.

AND/OR truth table

Condition A
0 0 1 1

Condition B 0 1 0 1

AND 0 0 0 1

OR 0 1 1 1

NOT truth table True = T or 1 False = F or 0 The NOT logic operator reverses the logic or result of a certain condition !A

Condition A
0 1 1 0

Try this

Condition A
0 0 0 0 1 1 1

Condition B
0 0 1 1 0 0 1

Condition C
0 1 0 1 0 1 0

A AND B

B OR C

1

1

1

Relational Operators Relational Operators are used in order to get the Boolean result of certain conditions.

Boolean Result:
The result may be a TRUE or FALSE value, depending on the condition that is being evaluated. The relational Operator may be the following: < Less than > Greater than <= Less than equal >= Greater than equal == Is equal to != not equal <> not equal

Assume that you have a variable called X and Y. What would be the results of the conditions if we were to compare them with different values and different relational operators? X 5 18 12 30 Y 17 4 12 31 < > <= >= == !=

More on Decision Box
We said that the diamond box is used for decision making within your flowchart. It should be noted that what you place inside the diamond box are conditions. Conditions that either results to TRUE or FALSE. NOTE: You don’t place conditions that are in essay form, you must be able to represent it in a mathematical form. Question: How do you know if X is less than 20?

X<20

Is variable X less than 20?

Single Alternative Selection Structure
A decision box may not necessarily have to do something for both the TRUE path and the FALSE path. You may opt to skip one part if need be.

F

T
T

F

STOP

Dual Alternative Selection Structure
The dual alternative selection structure performs two different things when the condition evaluates to true or to false.

T

F

CONDITIONAL STATEMENTS Flowchart Case Study 1: Draw a flowchart that will let the User enter a number, increase the Value of a number by 5 if it is greater 10 and display the result, otherwise do nothing.

Start

X=0

Enter X

TRUE

X >10

FALSE

X=X+5

Display X

Stop

Flowchart Case Study 2: Draw a flowchart that will let the user enter a number, increase the value of the number by 5 if it is greater than 10, and display the result; otherwise multiply the value by 5 and display the result.

START

X=0

Enter X

TRUE

X>1 0

FALSE

X=X+5

X=X*5

Display X

STOP

Flowchart Case Study 3: Draw a flowchart for a college’s admissions office. Create variables to store a student’s numeric high school grade point average and an admissions test score. Print the message “Accept” if the student has a grade point average of 3.0 or above and an admission test score of at least 60. If the student does not meet either of the qualification criteria, print the message “Reject”.

Start

Ave = 0.0 Test = 0

Enter Ave, Test

TRUE

Ave>=3. 0

FALSE

TRUE

Test>=6 0

FALSE

Display “Accept”

Display “Reject”

Stop

Multiple Decision box Not all the times multiple decision box can be combined in one box. There are times that you have to be very specific with the conditions that you have to put in.

Flowchart Case Study:
Let the user enter a number from 1 – 3. If the user inputs a ‘1’, print “Hello”, if the user inputs a ‘2’, print “Hi”, and if the user inputs a ‘3’, then print “Bye”. Otherwise print “Invalid Number” Start

X=0

Enter x

X= =1 FALSE X= =2 FALSE X= =3 FALSE

TRUE

Display “Hello”

TRUE

Display “Hi” STOP

TRUE

Display “Bye” Display “Invalid number”

Using Decision box with ranges Business programs often need to make selections based on a variable falling within a range of values. To perform a range check, use either the lowest or highest value in each range of values you are using to make your selections. Example: Create a flowchart that would print the name of the supervisor under a certain department number. Department Number 1-3 4-7 8.9 Supervisor Mr. X Mr. Y Mr. Z

START

Dept = 0

Enter Dept

X<=3

TRUE

Display “Mr. X”

FALSE

X<=7

TRUE

Display “Mr. Y”

STOP

FALSE Display “Mr. Z”

2 nd solution

START

Dept = 0

Enter Dept

X>=8

TRUE

Display “Mr. Z”

FALSE

X>=4

TRUE

Display “Mr. Y”

STOP

FALSE Display “Mr. X”

LOOPING CONSTRUCT

What is a loop?
In programming, a set of program instructions that executes repeatedly until a condition is satisfied.

LOOP LOOP

START

INITIALIZATION INITIALIZATION RUN RUN TRUE TRUE

CONDITION CONDITION

VARIABLE VARIABLE

USER INPUT USER INPUT

STOP STOP

FALSE FALSE

In the flowchart segment, the question - “is x < y?” is asked. If the answer is ‘Yes’ then Process A is performed. The question “is x < y?” is asked again. Process A is repeated as long as the question (condition) evaluates to True. When x is no longer less than y, the question (condition then evaluates to False, the repetition stops and the structure is exited.

X< y
FALSE

TRUE

Process A

The Action Performed by a repetition structure must eventually cause the loop to terminate. Otherwise, an infinite loop is created. In this flowchart segment, x is never changed. Once the loop starts, it will never end. TRUE

X<Y
FALSE QUESTION: How can this flowchart be modified so it is no longer an infinite loop? ANSWER: By adding an action within the repetition That changes the value of x.

Display X

Pre-test Repetition Structure:
This type of structure is known as a Pre-Test Repetition structure. The condition is tested BEFORE any actions are performed. In a pre-test repetition structure, if the condition does not exist, the loop will never begin.

X< Y
FALSE

TRUE

DISP X

X=X+1

Post-test Repetition Structure:
This flowchart segment shows a Post-Test Repetition structure. The condition is tested AFTER the actions are performed. A Post-Test repetition structure always perform its action at least once.

Display X

X=X+1

X< Y
FALSE

TRUE

FLOWCHART CASE STUDY:
Create a flowchart that will display the following result: (assume that the variable is initialized to 5)

START

X=5

X> 0
FALSE

TRUE

Display X
Output: 5 4 3 2 1 Done

Display “Done”

X=X-1

STOP

FLOWCHART CASE STUDY:
Create a flowchart that will print a series of numbers, based on what was entered by the user.

Number Entered:
4

START

X=0 Y=0

Enter Y

Output:
1 2 3 4 Done

X<Y
FALSE

TRUE

X = X+1

Display “Done”

Display X

STOP

FLOWCHART CASE STUDY:
Create a flowchart that will print the sum of all odd numbers from 1-100

START

sum = 1 ctr = 1

ctr<100
FALSE

TRUE

ctr = ctr+2

sum = sum + ctr

Display sum

STOP

NESTED LOOPS: It is possible to have a loop within a loop. In case of multiple loops, it is critical to determine what condition will terminate the whole flowchart.

dition This con e the will caus top. loop to s

Multiple loops are useful if there is a need to perform repetitive tasks, in other words, repeating tasks. Aside from that, nested loops are also useful for user input validations. For example, suppose you will let the user enter a number but you don’t allow a 0 or a negative number