introduction to basic programming.ppsx

34

Upload: cfbernas

Post on 19-Jul-2016

18 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Introduction to Basic Programming.ppsx
Page 2: Introduction to Basic Programming.ppsx

Steps in Programming Programming

Languages Algorithm Flowcharting

Before we begin programming, let us understand some basic concepts of programming.

Basic Concepts of Programming

Page 3: Introduction to Basic Programming.ppsx

Steps in Programming Algorithm Flowcharting

Basic Concepts of Programming

A computer program is an organized list of instructions that, when executed, causes the computer to behave in a predetermined manner. Without programs, computers are useless. Therefore, programming means designing or creating a set of instructions to ask the computer to carry out certain jobs which normally are very much faster than human beings can do. (Webopedia)

Program

Programming Concepts

Programming Languages

Page 4: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

A basic command. The term instruction is often used to describe the most rudimentary programming commands. For example, a computer's instruction set is the list of all the basic commands in the computer's machine language. (Webopedia)

Instruction

Programming Concepts

Programming Languages Steps in Programming Algorithm

Page 5: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

Computer instructions or data. Anything that can be stored electronically is software. (Webopedia)

Software

Programming Concepts

Software is often divided into two categories: 1. Systems software : Includes the operating system and all the utilities that enable the computer to function. Other examples of system software are compilers and interpreters. 2. Applications software : Includes programs that do real work for users. For example, word processors, spreadsheets, and database management systems fall under the category of applications software.

Programming Languages Steps in Programming Algorithm

Page 6: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

Programming Concepts

Applications Software

Systems Software

A program or group of programs designed for end users.

Refers to the operating system and all utility programs that manage computer resources at a low level.

Programming Languages Steps in Programming Algorithm

Page 7: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

The most important program that runs on a computer. Every general-purpose computer must have an operating system to run other programs. Operating systems perform basic tasks, such as recognizing input from the keyboard, sending output to the display screen, keeping track of files and directories on the disk, and controlling peripheral devices such as disk drives and printers.

Operating System

Programming Concepts

For large systems, the operating system has even greater responsibilities and powers. It is like a traffic cop -- it makes sure that different programs and users running at the same time do not interfere with each other. The operating system is also responsible for security, ensuring that unauthorized users do not access the system.

Programming Languages Steps in Programming Algorithm

Page 8: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

Operating systems provide a software platform on top of which other programs, called application programs, can run. The application programs must be written to run on top of a particular operating system. Your choice of operating system, therefore, determines to a great extent the applications you can run. For PCs, the most popular operating systems are DOS, OS/2, and Windows, but others are available, such as Linux.

Operating System

Programming Concepts

Programming Languages Steps in Programming Algorithm

Page 9: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

A program that performs a very specific task, usually related to managing system resources. Operating systems contain a number of utilities for managing disk drives, printers, and other devices.

Utility Program

Programming Concepts

Programming Languages Steps in Programming Algorithm

Page 10: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

1. Word processor / Word Processing software A program or computer that enables you to perform word processing functions.

Applications Software

Programming Concepts

2. Spreadsheet A table of values arranged in rows and columns. Each value can have a predefined

relationship to the other values. If you change one value, therefore, you may need to change other values as well. Spreadsheet applications (sometimes referred to simply as spreadsheets) are computer programs that let you create and manipulate spreadsheets electronically. In a spreadsheet application, each value sits in a cell. You can define what type of data is in each cell and how different cells depend on one another. The relationships between cells are called formulas, and the names of the cells are called labels.

Programming Languages Steps in Programming Algorithm

Page 11: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

3. Database Management System

Applications Software

Programming Concepts

A collection of programs that enables you to store, modify, and extract information from a database. There are many different types of DBMSs, ranging from small systems that run on personal computers to huge systems that run on mainframes.

The following are examples of database applications: • computerized library systems • automated teller machines • flight reservation systems • computerized parts inventory systems

Programming Languages Steps in Programming Algorithm

Page 12: Introduction to Basic Programming.ppsx

Flowcharting

Programming means designing or creating a set of instructions to ask the computer to carry out certain jobs which normally are very much faster than human beings can do. (Webopedia)

Programming

Programming Languages

Programming is the iterative process of writing or editing source code. Editing source code involves testing, analyzing, and refining. A person who practices this skill is referred to as a computer programmer or software developer. The sometimes lengthy process of computer programming is usually referred to as software development.

Programming Languages

Basic Concepts of Programming

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 13: Introduction to Basic Programming.ppsx

Programming Languages Flowcharting

Basic Concepts of Programming

Programming Languages A programming language acts as a translator between you and the computer. Rather than learning the computer's native language (known as machine language), you can use a programming language to instruct the computer in a way that is easier to learn and understand. A vocabulary and set of grammatical rules for instructing a computer to perform specific tasks. The term programming language usually refers to high-level languages, such as BASIC, C, C++, COBOL, FORTRAN, Ada, and Pascal. Each language has a unique set of keywords (words that it understands) and a special syntax for organizing program instructions.

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 14: Introduction to Basic Programming.ppsx

Flowcharting

As an electronic device, the computer has a unique language that converts the data we input into a format that the computer can understand . The data we input into the computer turns into electronic pulses which can either be “on” or “off” or “0” and “1” codes in the binary system. So, the CPU only understands a combinations of “0” and “1” codes, a language which we called machine language.

The Language of Computing

Programming Languages

Basic Concepts of Programming

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 15: Introduction to Basic Programming.ppsx

Flowcharting

There are two levels of programming languages: low-level language and high-level language

Levels of Programming Languages

Programming Languages

Basic Concepts of Programming

1. Low-level languages

Machine Language is a computer language, entirely in binary digits representing instructions and information, used directly by a computer without translation.

is a language that is written at the most basic level of computer operation. As such, it is more directly understood by the computer. For programmers, however, it is cumbersome and hard to understand. The two low-level languages are machine language and assembly language.

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 16: Introduction to Basic Programming.ppsx

Flowcharting

The lowest-level programming language (except for computers that utilize programmable microcode) Machine languages are the only languages understood by computers. While easily understood by computers, machine languages are almost impossible for humans to use because they consist entirely of numbers. Programmers, therefore, use either a high-level programming language or an assembly language. An assembly language contains the same instructions as a machine language, but the instructions and variables have names instead of being just numbers. (Webopedia)

Machine Language

Programming Languages

Basic Concepts of Programming

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 17: Introduction to Basic Programming.ppsx

Flowcharting

Machine language is extremely difficult to learn and it is not for us laymen to master it easily. Fortunately , we have many smart programmers who wrote interpreters and compilers that can translate human language-like programs such as BASIC into machine language so that the computer can carry out the instructions entered by the users.

Machine Language

Machine language is known as the primitive language while Interpreters and compilers like Visual Basic are called high-level language.

Programming Languages

Basic Concepts of Programming

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 18: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

A program that translates source code into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instructions. Thus, a compiler differs from an interpreter, which analyzes and executes each line of source code in succession, without looking at the entire program. The advantage of interpreters is that they can execute a program immediately. Compilers require some time before an executable program emerges. However, programs produced by compilers run much faster than the same programs executed by an interpreter. (Webopedia)

Compiler

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Programming

Languages Algorithm

Page 19: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

An interpreter translates high-level instructions into an intermediate form, which it then executes. In contrast, a compiler translates high-level instructions directly into machine language. Compiled programs generally run faster than interpreted programs. The advantage of an interpreter, however, is that it does not need to go through the compilation stage during which machine instructions are generated. This process can be time-consuming if the program is long. The interpreter, on the other hand, can immediately execute high-level programs. For this reason, interpreters are sometimes used during the development of a program, when a programmer wants to add small sections at a time and test them quickly. In addition, interpreters are often used in education because they allow students to program interactively. (Webopedia)

Interpreter A command interpreter is the part of a computer operating system that understands and executes commands that are entered interactively by a human being.

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Programming

Languages Algorithm

Page 20: Introduction to Basic Programming.ppsx

Flowcharting

Programs written in high-level languages are translated into assembly language or machine language by a compiler. Assembly language programs are translated into machine language by a program called an assembler.

Every CPU has its own unique machine language. Programs must be rewritten or recompiled, therefore, to run on different types of computers.

Programming Languages

Basic Concepts of Programming

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 21: Introduction to Basic Programming.ppsx

Flowcharting

A programming language that is once removed from a computer's machine language. Machine languages consist entirely of numbers and are almost impossible for humans to read and write. Assembly languages have the same structure and set of commands as machine languages, but they enable a programmer to use names instead of numbers. (Webopedia)

Assembly Language

Each type of CPU has its own machine language and assembly language, so an assembly language program written for one type of CPU won't run on another. In the early days of programming, all programs were written in assembly language. Now, most programs are written in a high-level language. Programmers still use assembly language when speed is essential or when they need to perform an operation that isn't possible in a high-level language.

Programming Languages

Basic Concepts of Programming

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 22: Introduction to Basic Programming.ppsx

Flowcharting

Programming Languages

Basic Concepts of Programming

High-level languages Even with assembly language, however, programmers saw that writing programs was still too complicated. Simple instructions, like finding the sum of 2 numbers, still required too many steps. In 1950s, programmers began to develop languages that could relieve them from the burdensome details of writing programs in low-level languages. These “set-up” languages are called high-level languages. Written in an English-like manner and using many English words, these languages offer convenience and simplicity for programmers.

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 23: Introduction to Basic Programming.ppsx

Flowcharting

Programming Languages

Basic Concepts of Programming

High-level languages

A programming language such as C, FORTRAN, or Pascal that enables a programmer to write programs that are more or less independent of a particular type of computer. Such languages are considered high-level because they are closer to human languages and further from machine languages. In contrast, assembly languages are considered low-level because they are very close to machine languages. The main advantage of high-level languages over low-level languages is that they are easier to read, write, and maintain. Ultimately, programs written in a high-level language must be translated into machine language by a compiler or interpreter.

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 24: Introduction to Basic Programming.ppsx

Flowcharting

Programming Languages

Basic Concepts of Programming

Lying between machine languages and high-level languages are languages called assembly languages. Assembly languages are similar to machine languages, but they are much easier to program in because they allow a programmer to substitute names for numbers. Machine languages consist of numbers only. Lying above high-level languages are languages called fourth-generation languages (usually abbreviated 4GL). 4GLs are far removed from machine languages and represent the class of computer languages closest to human languages.

The other four generations of computer languages are : • First generation: machine language • Second generation: assembly language • Third generation: high-level programming languages, such as C, C++, and Java. • Fifth generation: languages used for artificial intelligence and neural networks.

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 25: Introduction to Basic Programming.ppsx

Flowcharting

Basic Concepts of Programming

High-level Programming Languages Some of the high level computer languages beside Visual Basic are Fortran, Cobol, Java, C++, Turbo Pascal, and etc.

1. FORTRAN stands for FORmula TRANslator and it was developed by IBM Inc. between 1954 and 1957 which was used specifically for scientific ad engineering applications. It is still widely used today in the engineering fields.

2. COBOL stands for Common Business Oriented Language which was created by a group of computer manufacturers and industrial computer users in 1959. It was designed for commercial applications that required large amount of data processing. It is still being used today in the business fields.

Programming Languages

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 26: Introduction to Basic Programming.ppsx

Flowcharting

Programming Languages

Basic Concepts of Programming

High-level Programming Languages 3. C was developed by Dennis Richie at Bell Laboratories in 1972. It is a system implementation language that was used to develop the UNIX operating system.

4. C++ is an extension of C which was created by Bjarne Stroustrup in 1980's. It added the OOP (Object-Oriented Programming) feature to C and now it is the main systems implementation language (Deitel&Deitel, 1999) .

5. PASCAL was created by Professor Nicklaus Wirth for teaching the concepts of structured programming. Its use is primarily confined to the academic world.

6. JAVA is the latest but one of the hottest programming languages developed by the Sun Microsystems in 1995. It was actually an extension of C++ but it has included extensive libraries for doing multimedia, networking, multithreading , graphics, database access, GUI programming. Microsoft also come out with its own version of Javawhich is known as Visual J++.

Programming Languages 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Steps in Programming Algorithm

Page 27: Introduction to Basic Programming.ppsx

Steps in Programming Flowcharting

Basic Concepts of Programming

Steps in Programming The five steps in the programming process are:

1. Define the Problem – discuss problem with the users of a system and the systems analyst to determine the necessary input, processing, and output .

2. Design the Solution – design an algorithm and represent the logic using a Flowcharts or Pseudocode 3. Write the Program – express the solution in a programming language 4. Test and Debug the Program – translate and debug. Insure that the program works as planned (Use an Interpreter or Compiler - Run or Execute the Commands which translate source code into object code)

Programming Languages

Steps in Programming

Algorithm

Page 28: Introduction to Basic Programming.ppsx

Steps in Programming Flowcharting

Basic Concepts of Programming

interpreter - translates line by line from source code (actual programming language) into object code, and identifies syntax errors (violations in using programming language instructions)

compiler - translates entire program of source code (actual programming language) into object code, and identifies syntax errors .

5. Document Throughout – provide material that supports the design, development, and testing of the program. Listings of your source code is a type of documentation, so are comments within the source code as well as user manuals.

Steps in Programming

Programming Languages

Steps in Programming

Algorithm

Page 29: Introduction to Basic Programming.ppsx

Algorithm Flowcharting

Basic Concepts of Programming

ALGORITHM

Algorithm

An algorithm (pronounced AL-go-rith-um) is a procedure or formula for solving a problem. The word derives from the name of the mathematician, Mohammed ibn-Musa al-Khwarizmi, who was part of the royal court in Baghdad and who lived from about 780 to 850. Al-Khwarizmi's work is the likely source for the word algebra as well.

A computer program can be viewed as an elaborate algorithm. In mathematics and computer science, an algorithm usually means a small procedure that solves a recurrent problem

An algorithm is a procedure for solving a problem; more specifically, it is a series of steps that should be followed exactly to produce a desired result.

Steps in Programming Programming

Languages

Page 30: Introduction to Basic Programming.ppsx

Algorithm Flowcharting

Basic Concepts of Programming

STRUCTURED PROGRAMMING • is a technique that emphasizes the breaking of a program – or algorithm – into logical sections, or modules, following a universal programming standard.

Steps in Programming Programming

Languages

• is a computer programming in which the statements are organized in a specific manner to minimize error or misinterpretation.

• techniques that impose a logical structure on the writing of a program. Large routines are broken down into smaller, modular routines.

Structured programming (sometimes known as modular programming) is a subset of procedural programming that enforces a logical structure on the program being written to make it more efficient and easier to understand and modify.

Structured Programming

Page 31: Introduction to Basic Programming.ppsx

Algorithm Flowcharting

Basic Concepts of Programming

To control the flow of our algorithm or programs, structured programming

employs what is called “control structures” - a step, or series

of steps, that determines what instruction or set of instructions will be done next.

Steps in Programming Programming

Languages

CONTROL STRUCTURES There are three basic control structures we must be familiar with: sequence, selection and iteration.

Control Structures

Page 32: Introduction to Basic Programming.ppsx

Algorithm Flowcharting

Basic Concepts of Programming Steps in Programming

Programming Languages

Sequence Control Structure

The sequence control structure is the most straightforward of all the control structures. In this case, your algorithm or program will just follow instructions or statements one after the other in sequence.

Process 2

Process 3

Process 1

start

end

( No Branching)

Sequence Control Structure

Page 33: Introduction to Basic Programming.ppsx

Algorithm Flowcharting

Basic Concepts of Programming Steps in Programming

Programming Languages

Selection Control Structure

In a selection structure, a question is asked, and depending on the answer, the program takes one of two courses of action, after which the program moves on to the next event. Also called decision control structure.

(Branching Forwards) start

start

IF (condition)

Process Process

yes no

This structure is sometimes referred to as an if-then-else because it directs the program to perform in this way: If Condition A is True then perform Action X else perform Action Y.

Selection Control Structure

Page 34: Introduction to Basic Programming.ppsx

Algorithm Flowcharting

Basic Concepts of Programming Steps in Programming

Programming Languages

Iteration / Loop Control Structure

A single pass through a group of instructions. Most programs contain loops of instructions that are executed over and over again. The computer iterates through the loop, which means that it repeatedly executes the loop

(Branching Backwards) start

end IF (condition)

Process

yes

no In a loop structure, the program asks a question, and if the answer requires an action, it is performed and the original question is asked again until the answer is such that the action is no longer required.

Each pass through the loop is called an iteration.

Iteration / Loop Control Structure