0% found this document useful (0 votes)
63 views

Introduction To Computer

This document introduces computer programming by defining its objectives, components of a computer, types of computer programs, programming languages, categories of programming languages, and the program development life cycle. It explains that a computer has hardware and software components and identifies systems programs, application programs, and compilers as types of computer programs. It also defines programming languages, high-level and low-level languages, and describes the typical steps in the program development life cycle: problem definition, problem analysis, algorithm design, coding, and debugging.

Uploaded by

Joey L. Argueza
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Introduction To Computer

This document introduces computer programming by defining its objectives, components of a computer, types of computer programs, programming languages, categories of programming languages, and the program development life cycle. It explains that a computer has hardware and software components and identifies systems programs, application programs, and compilers as types of computer programs. It also defines programming languages, high-level and low-level languages, and describes the typical steps in the program development life cycle: problem definition, problem analysis, algorithm design, coding, and debugging.

Uploaded by

Joey L. Argueza
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Introduction to Computer Programming

Objectives
Identify the different components of a computer Know about programming languages and their categories Understand the program development life cycle and apply it in problem solving To create a flowchart using problem sets.

A computer is a machine that performs a variety of tasks according to specific instructions. It is a data processing machine which accepts data via an input device and its processor manipulates the data according to a program. The computer has two major components. The first one is the Hardware which is the tangible part of the computer. It is composed of electronic and mechanical parts. The second major component is the software which is the intangible part of a computer. It consists of data and the computer programs.

Some Types of Computer Programs:


1. Systems Programs Programs that are needed to keep all the hardware and software systems running together smoothly Examples: Operating Systems like Linux, Windows, Unix, Solaris, MacOS 2. Application Programs Programs that people use to get their work done Examples: Word Processor Game programs Spreadsheets 3. Compilers The computer understands only one language: machine language. Machine language is in the form of ones and zeros. Since it is highly impractical for people to create programs out of zeros and ones, there must be a way of translating or converting a language which we understand into machine language, for this purpose, there exists compilers.

What is a Programming Language?


A programming language is a standardized communication technique for expressing instructions to a computer. Like human languages, each language has its own syntax and grammar. Programming languages enable a programmer to precisely specify what data a computer will act upon, how these data will be stored/transmitted, and precisely what actions to take under various circumstances. There are different types of programming languages that can be used to create programs, but regardless of what language you use, these instructions are translated into machine language that can be understood by computers.

Categories of Programming Languages


1. High-level Programming Languages A high-level programming language is a programming language that is more userfriendly, to some extent platform-independent, and abstract from low-level computer processor operations such as memory accesses. A programming statement may be translated into one or several machine instructions by a compiler. Examples are Java, C, C++, Basic, Fortran

2. Low-level Assembly Language


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. Assembly languages are available for each CPU family, and each assembly instruction is translated into one machine instruction by an assembler program. Note: The terms "high-level" and "low-level" are inherently relative. Originally, assembly language was considered low-level and COBOL, C, etc. were considered high-level. Many programmers today might refer to these latter languages as low-level.

The Program Development Life Cycle Programmers do not sit down and start writing code right away when trying to make a computer program. Instead, they follow an organized plan or methodology, that breaks the process into a series of tasks. Basic steps in trying to solve a machine problem: 1. Problem Definition 2. Problem Analysis 3. Algorithm design and representation (Pseudocode or flowchart) 4. Coding and debugging

1. Problem Definition A programmer is usually given a task in the form of a problem. Before a program can be designed to solve a particular problem, the problem must be well and clearly defined first in terms of its input and output requirements.
A clearly defined problem is already half the solution. Computer programming requires us to define the problem first before we even try to create a solution.

Let us now define our example problem: Create a program that will determine the number of times a particular name occurs in a list.

2. Problem Analysis After the problem has been adequately defined, the simplest and yet the most efficient and effective approach to solve the problem must be formulated. Usually, this step involves breaking up the problem into smaller and simpler subproblems. Example Problem: Determine the number of times a name occurs in a list Input to the program: list of names, name to look for Output of the program: the number of times the name occurs in a list

3. Algorithm design and representation Once our problem is clearly defined, we can now set to finding a solution. In computer programming, it is normally required to express our solution in a step-by-step manner. An Algorithm is a clear and detailed specification of the steps needed to solve a problem. It may be expressed in either Human language (English, Tagalog), through a graphical representation like a flowchart or through a pseudocode, which is a cross between human language and a programming language.

Expressing our solution through Human language: 1. Get the list of names. 2. Get the name to look for, let's call this the keyname. 3. Compare the keyname to each of the names in the list. 4. If the keyname is the same with a name in the list, add 1 to the count. 5. If all the names have been compared, output the result.

Expressing our solution through a flowchart:

Expressing our solution through pseudocode: Let nameList = List of Names Let keyName = the name to be sought Let Count = 0 For each name in NameList do the following if name == keyName Count = Count + 1 Display Count

Flowcharting Symbols and their meanings


A flowchart is a design tool used to graphically represent the logic in a solution. Flowcharts typically do not display programming language commands. Rather, they state the concept in English or mathematical notation.

Coding and Debugging After constructing the algorithm, it is now possible to create the source code. Using the algorithm as basis, the source code can now be written using the chosen programming language. Most of the time, after the programmer has written the program, the program isn't 100% working right away. The programmer has to add some fixes to the program in case of errors (also called bugs) that occurs in the program. This process of is called debugging. There are two types of errors that a programmer will encounter along the way. The first one is compile-time error, and the other is runtime error.

Compile-Time Errors occur if there is a syntax error in the code. The compiler will detect the error and the program won't even compile. At this point, the programmer is unable to form an executable that a user can run until the error is fixed.
Forgetting a semi-colon at the end of a statement or misspelling a certain command, for example, is a compile-time error. It's something the compiler can detect as an error.

Compilers aren't perfect and so can't catch all errors at compile time. This is especially true for logic errors such as infinite loops. This type of error is called runtime error.

You might also like