Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
37 views

Lesson 1-Introduction To Programming

Categories of Programming Languages Program Development Life cycle programming paradigm Program Structure

Uploaded by

Josephus Toledo
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Lesson 1-Introduction To Programming

Categories of Programming Languages Program Development Life cycle programming paradigm Program Structure

Uploaded by

Josephus Toledo
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

1

INTRODUCTION TO COMPUTER PROGRAMMING


Today, most people don't need to know how a computer works. Most people can simply
turn on a computer or a mobile phone and point at some little graphical object on the display,
click a button or swipe a finger or two, and the computer does something. An example would be
to get weather information from the net and display it. How to interact with a computer program
is all the average person needs to know.

But, since you are going to learn how to write computer programs, you need to know a
little bit about how a computer works. Your job will be to instruct the computer to do things.
Basically, writing software (computer programs) is describing how to do something. In its
simplest form, it is a lot like writing down the steps it takes to do something. The lists of
instructions that you will write are computer programs, and the stuff that these instructions
manipulate are different types of objects, e.g., numbers, words, graphics, etc...

So, writing a computer program can be like composing music, like designing a house,
like creating lots of stuff. It has been argued that in its current state it is an art, not engineering.
An important reason to consider learning about how to program a computer is that the concepts
underlying this will be valuable to you, regardless of whether or not you go on to make a career
out of it. One thing that you will learn quickly is that a computer is very dumb but obedient. It
does exactly what you tell it to do, which is not necessarily what you wanted.

What is a Programming Language?

Conceptually in English Subject, we define language as “medium of communications”.


Where communication brings up conversation and carries out understanding. But it is
impossible to communicate with a computer using the human’s spoken language such as
Filipino or English. Therefore, we must adapt to the machine and learn a language that the
computer can understand.

Programming Language - is a language that is used in creating a set of codes to communicate


with the computer system. This 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.
2

Categories of Programming Language

Low-level Programming Languages – are similar to machine languages, but they are much
easier program because they allow a programmer to substitute names for numbers. Assembly
language is equipped with an assembler program.

Ex. Turbo Assembly

High-level Programming Languages - Human understandable program code in formulating


programs and procedure to give instruction for a computer work. Translation of programming
statement is done by a compiler.

Ex. Java, Vb.net, C, C++, Basic, Fortran

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.

Programmer’s Notes

Software - Software is a generic term for organized collections of computer data and
instructions
Program – are the instructions given to the computer to arrive at a certain result.
Programmer – person specialized in creating computer programs.
Programming – is the process of giving instruction to a computer.
Data - any facts, numbers, or text that can be processed by a computer.
Code – is a set of symbols and/or command used to create a program.
Compiler – program that translate high level programming statements into one or several
machine instructions.
Assembler – program that translate assembly statements into machine instructions.
Machine Language - it is the natural language of a particular computer. It is also called as
Binary Language (1 and 0).
3

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 task.

Here are the basic steps in trying to solve a problem on the computer.

STEP PROCEDURE
1 Problem Definition
2 Problem Analysis
3 Algorithm design and Representation
4 Coding and Debugging

Let’s discuss it one


by one.
Step 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 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 no define our example problem:


“Create a program that will determine and display the area of a square”

Step 2: Problem Analysis

After the problem has been adequately defined, the simplest and yet most efficient and
effective approach to solve the problem must be formulated. Usually this step involves breaking
up the problem into smaller and simple sub problems.

Example Problem:
Determine and display the area of a square
Input to the Program:
Sides
4

Process:
Computation Formula: Area=Sides * Sides
Output of the Program:
Area of Square

Step 3: Algorithm design and representation

Once our problem is clearly defined, we can now set to find a solution. In computer
programming, it is normally required to express our solution in a step-by-step manner. Solution
may express through flowchart or pseudocode.

Expressing Solution through flowchart:

START Expressing Solution through Pseudocode:

S=0, A=0
1. Set the side and area of the square into zero
2. Read the side of the square
Get S
3. Compute the area using the formula: A=S * S
4. Display the area
A= S * S

Display Programmer’s Notes


A
Syntax – is the set of rules that defines the combinations of
symbols that are considered to be correctly structured
END
document or fragment in that language.
Algorithm – is a clear and unambiguous specification of the
Vocabulary used in the
pseudocode should be the steps needed to solve a problem.
vocabulary of the problem Flowchart – is a diagram representing the logical sequence
domain, not of the
implementation domain. which is a combination of the steps or operations to be
performed.
Pseudocode - is a kind of structured english for describing
algorithms. It allows the designer to focus on the logic of the
algorithm without being distracted by details of language
syntax.
5

Step 4: 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 programming language.

Sample Code:

Module Square

Dim s, a As Double

Sub Main()

Console.Write("Input Side: ")

s = Console.ReadLine

a=s*s

Console.Write("Area is: " & a)

Console.ReadKey()

End Sub

End Module

Most of the time, after 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 bugs.
This process 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 other is runtime error.
Programmer’s Notes
Compile-Time Errors – Occur if there is a syntax error
Bugs – This are the errors occurs in the
in the code. The compiler will detect error and the
program
program won’t even compile.
Debugging – process of correcting
(Ex. Forgetting to put a comma)
bugs

Runtime Error – This error are also called logic error. The compiler can’t detect as an error.
(Ex. Infinite Loop or incorrect value is computed)
6

Programming Paradigms

A programming paradigm is a style or "way" of programming. Some languages make it


easy to write in some paradigms but not others. Some of the more common paradigms are:
Imperative, Structured, Procedural, Object-oriented and Declarative.

Paradigm Description Main characteristics

kind of imperative programming


where the control flow is defined Indentation, either no, or limited use
Structured
by nested loops, conditionals, of, goto statements
and subroutines

Derived from structured


programming, based on the Local variables, sequence,
Procedural concept of modular selection, iteration,
programming or the procedure and modularization
call

Objects, methods, message


Treats data fields as objects
passing, information hiding, data
Object-oriented manipulated through pre-
abstraction, encapsulation,
defined methods only
polymorphism, inheritance

From the listed programming paradigms above, we will choose one to be our
programming style. Let’s take a closer look on Structured Programming.

Structured Programming

Structured Programming is a methodology used to facilitate translating the problem


analyzed into the specific program, modules, procedures and functions. The entire program
with a lot lines of codes may be broken into several levels of even smaller, more precise sets of
instructions.
7

In structured programming, all program logic is constructed from a combination of three


control structures.

Program Structure

a. Sequence Control Structure – is used to show a single action or one action followed in
order (sequentially) by another. Actions can be input, process or output.

Action 1 Action 2 Action 3

b. Selection Control Structure – is used to tell the program which action to take, based
on a certain condition. When the condition is evaluated, its result is either true or false.
If the result of the condition is true, one action is performed, and different action is
performed if the result of the condition is false.

Action 1 Condition Action 2

c. Repetition Control Structure – also called as looping or iteration is used when a set of
actions is to be performed repeatedly.

Action 1 Action 2 Action 3

You might also like