Вы находитесь на странице: 1из 9

1.1. What is Programming?

A problem is defined as any question, something involving doubt, uncertainty, difficulty or a situation
whose solution is not immediately obvious. A situation which is a problem for one person may not be
a problem for another person. Figure 1.1 graphically represents the concept of problem solving.
A Computer is a tool that can be used to solve problems by writing programs. Writing a program
without knowing the problem that we are trying to solve is like swinging a knife without knowing what
it is that we want to cut.
A program is a set of instructions that tells the computer how to do a task. When a computer follows
these instructions, we say it executes the program

Fig 1.1: Problem Solving


A programming language is a computer language that programmers use to develop applications. An
application is a set of instructions for a computer to execute. A set of rules that provides a way of
telling a computer what operations to perform is called a Program.
Programming is the process of designing, developing, testing, debugging and maintaining the source
code of computer programs. It is used to create a set of instructions that computers use to perform
specific operations or to exhibit desired behaviors. Source code can be written using programming
language such as C++, Java, Python, Smalltalk, C#, etc. The process of writing source code often
requires expertise in many different subjects, including knowledge of the specialized algorithms,
application domain and formal logic.
Within software engineering, programming (implementation) is considered as a phase in the
software development process.
The Programming Process
Developing a program involves different steps similar to any problem solving task. There are five
main steps in the programming process. They are as follows:
1. Defining the problem
2. Planning the solution
3. Coding the program
4. Testing the program

5. Documenting the program


Let us discuss each of these steps.
1. Defining the problem
As a programmer, you meet with end users from the client organization to analyze the problem, or
you meet with a systems analyst who outlines the project. Specifically, the task of defining the
problem consists of identifying what you know (input-given data), and what you want to obtain
(output-the result). Eventually, you create a document or an agreement that specifies the kind of
input, processing, and output required to complete the task.
2. Planning the solution
There are two ways that are commonly used to plan the solution to a problem. These are to draw a
flowchart and to write pseudo code, or both.
Pseudo code
Pseudo code is an English-like non-standard langauge that permits you to focus on the program
logic without having to be concerned about the precise syntax of a particular programming language.
However, pseudo code is not executable on the computer. It lets you state your solution with more
precision than plain English. However psuedo code has lesser precision than is required when using
a formal programming language. An example is given below:
Example : Read number n and print the integers counting up to n.
Read n
Initialize the variable i to 1
while i 'less than or equal to n' do
Print i
Increment i
end while
Stop
In the above example, the program enters the while loop only if the condition (i less than or equal to
n) is true. Two statements Print i and Increment i are executed for each iteration. At the end of each
iteration, the condition is evaluated again and the loop continues as long as the condition is true.
Flowchart
It is a pictorial representation of a step-by-step solution to a problem. It consists of arrows
representing the direction the program takes and boxes and other symbols representing actions. It is
a map of the steps involved in a program. The American National Standards Institute (ANSI) has
come up with a standard set of flowchart symbols. The following figure shows the flowchart symbols

and how they might be used in a simple flowchart of an everyday action preparing a letter for
mailing.

Figure 1.2: Flowchart


Please refer the links below to learn more about pseudo code and flow chart.
http://ceng.anadolu.edu.tr/emrekacmaz/bil158/flowchart-pseudocode-examples.pdf
http://ozark.hendrix.edu/~burch/csbsju/cs/150/sched/pseudo.pdf
http://www.cosc.canterbury.ac.nz/tim.bell/dt/Tutorial_Pseudocode.pdf
http://users.csc.calpoly.edu/~jdalbey/SWE/pdl_std.html

3. Coding the program


As a programmer, your next step is to code the program to express the solution in a programming
language. You will translate the logic from the flowchart or pseudo code to a programming language.
As we have already discussed, a programming language is a set of rules that provides a way of

instructing the computer what operations to perform. There are many programming languages such
as BASIC, COBOL, Pascal, FORTRAN, C, etc.
Programming languages are precise like the English language. To get your program to work, you
have to follow the exact syntax (rules) of the language you are using. However, there is no
guarantee that your program will work because the syntax in programming language is correct. The
correctness of the language is the first step that you require. After that, the program must be keyed,
probably using a personal computer, in a form that the computer can understand.

4. Testing the program


Some experts claim that a well designed program can be written correctly the first time and there are
mathematical ways to prove that a program is correct. Most of the programs may have a few bugs
(errors) when executed for the first time. This is a little discouraging at first, since programmers tend
to be careful, precise and detail-oriented people who take pride in their work. There are many ways
in which mistakes or problems may happen in programs. You will probably have made some of
them. Eventually, after coding, we must prepare to test the program on the computer.
Testing involves three phases:
1. Desk-checking
2. Translating
3. Debugging
Let us discuss each of them.
Desk-checking
This is similar to proofreading. This phase is sometimes avoided by the developer/programmer who
is looking for a shortcut and is eager to run the program on the computer once it is written. However,
with careful desk-checking we can identify several errors and possibly save our time in the long run.
In desk-checking, you simply sit down and mentally check or trace the logic of the program in an
attempt to ensure that it is error-free and is in workable condition. Many organizations take this
phase a step further called walk through, a process in which a group of programmers review the
program and make suggestions or comments in a collegial way.
Translating
A translator is a program that
I. Checks the syntax of the program to make sure that the programming language was used
correctly, giving you all the syntax related error messages called diagnostics, and
II. Then translates the program into a form which the computer can understand. A by-product of the
process is that the translator tells us if we have improperly used the programming language. These
mistakes are called syntax errors. The translator gives descriptive error messages.

Programs are most commonly translated using a compiler. A compiler translates the entire program
at one time. The translation involves your original program (Source file) which is transformed by a
compiler into an object module. Pre-written programs from a system library may be added during the
load/link phase, which results in a load module. The load module can then be executed by the
computer.
Debugging
Debugging is used extensively in programming. It means detecting, locating, and correcting bugs
(mistakes) by running the program. These bugs are called as logic errors, which tells the computer to
repeat an operation but not telling it when to stop repeating. In this phase we run the program using
the test data that we devise. We must plan the test data carefully to make sure we test every part of
the program.

5. Documenting the program


Documenting is an ongoing process. It is a detailed description of the programming cycle and
specific facts about the program in the written form.
Typical program documentation include the origin and nature of the problem, a brief description of
the program, logic tools such as pseudo code and flowcharts, program listings, data-record
descriptions and test results. Comments in the program are also considered as an essential part of
documentation. Many programmers document as they code.
A wise programmer continues to document the program throughout its design, development and
testing. Documentation is used to supplement human memory and to help organize program
planning. Documentation is also critical to communicate with others who have an interest in the
program and may be part of a programming team.
Related Video/Material Links:
http://www.lynda.com/home/Player.aspx?lpk4=90430&playChapter=False
http://codingintro.com/chapter/en/1/introduction
http://www.cs.bham.ac.uk/~rxb/java/intro/2programming.html

1.2. Why programming is required?


We may have already used software, in the form of spreadsheets or word processing, or to solve
problems. Perhaps we are now curious to learn how programmers write software. A program is a set
of step-by-step instructions that directs the computer to do the tasks we want it to do and produce
the results we want.
There are three good reasons for learning programming:

1. Programming helps us to understand computers. If we learn how to write simple programs, we will
know better about how a computer works.
2. Writing a few simple programs increases our confidence level. We will find great personal
satisfaction in creating a set of instructions that solvea a problem.
3. Learning programming lets us find out quickly whether we like programming and whether we have
the analytical turn of mind that programmers need. Even if we decide that programming is not for us,
understanding the process certainly will increase our appreciation of what computers and
programmers can do.

What Programmers Do?


The programmer prepares the set of instructions of a computer program and runs those instructions
on the computer, tests the program to see if it is working properly, and then makes corrections to it.
These activities are all done for the purpose of helping a user to fill a need, such as paying
employees, admitting students to college or billing customers.
Programming can be done as a solo activity, but a programmer typically interacts with a variety of
people. For example, if a program is a part of a system of several programs, the programmer
coordinates with the other programmers to make sure that all the programs fit together correctly. If
you are a programmer, you might also have coordination meetings with users, systems analysts,
managers, and with peers who evaluate your work just as you evaluate theirs.

Levels of Language
Programming languages can be "lower" or "higher," depending on how close they are to the
language the computer itself uses (0s and 1s = low) or to the language people use (English like
high). We will consider five levels of language. These are numbered 1 through 5 to correspond to
generations. In terms of ease of use and capabilities, each generation or level is an improvement
over its predecessor.
The five generations of languages are:
1. Machine languages
2. Assembly languages
3. High-level languages
4. Very high-level languages
5. Natural languages
Let us look at each of these categories
1. Machine languages

Humans do not like to deal with numbers alone; they prefer letters and words also. Machine
language consists of numbers. Each type of computer has its own machine language. This is the
lowest level of language. It represents data and program instructions as 1s and 0s- the binary digits
corresponding to the on and off electrical states in the computer. During the early days of computing,
programmers used rudimentary systems for combining numbers to represent instructions such as
add or compare. These programs are not convenient for people to read and use, and the industry
quickly moved to develop assembly languages.
2. Assembly languages
Assembly languages are considered to be very low level languages. They are not as convenient to
use as the more recent languages. However, at the time when they were developed, they were
considered as a great leap forward. To replace the 1s and 0s used in machine language, the
assembly languages use mnemonic codes. Mnemonic codes are abbreviations that are easy to
remember: A for add, C for compare, MP for Multiply and so on. Although these codes are not
English words, they were better accepted than numbers (0s and 1s) alone. Just like machine
language, each type of computer has its own assembly language.
The programmer who uses an assembly language requires a translator to convert the assembly
language program into machine language. A translator is required because machine language is the
only language that the computer can actually execute. The translator is an assembler program,
which is also referred to as an assembler. It takes the programs written in assembly language and
converts them into machine language. Programmers need not worry about the translating aspect,
they only need to write programs in assembly language.
Although assembly languages represent a step forward, they still have many disadvantages. A key
disadvantage is that assembly language is detailed to the extreme, making assembly language
programming repetitive, error prone and tedious.
3. High-Level Languages
The widespread use of high-level languages in the early 1960's transformed programming into
something quite different from what it had been. Programs were written in an English-like manner,
thus making them easier and more convenient to use. Using high-level languages, a programmer
can accomplish more with less effort, and programs can now take care of much more complex tasks.
These so-called third generation languages spurred a great increase in data processing that
characterized the 1960's and 1970's. During that period, the number of mainframes in use increased
from hundreds to tens of thousands.
A translator is used to translate the symbolic statements of a high level language into computer
executable machine language. This translator is called a compiler. There are many compilers for
each language and one for each type of computer. For example, it is necessary to have a COBOL
compiler for each type of computer on which COBOL programs are to be run. A program can be
compiled to different machine language versions on different machines. The source program itself,
that is, the COBOL version is essentially identical on each machine.

Some languages are used to serve a specific purpose, such as creating graphics or controlling
industrial robots. Many languages are extraordinarily flexible and are considered to be generalpurpose languages. In the past, the majority of programming applications were written in BASIC,
COBOL or FORTRAN. All of them are general purpose languages.
4. Very High-Level Languages
Very high-level languages are often known by their generation number. They are called fourthgeneration languages or 4GLs. Fourth-generation languages are beneficial because:
I.They are result-oriented; they emphasize "what" instead of "how".
II.They improve productivity because programs are easy to write and modify.
III.They can be used with minimum training by both programmers and non-programmers.
IV.They shield users from needing an awareness of program structure and hardware.

5. Natural Languages
The word "natural" has become very popular in computing circles. Fifth generation languages are
often called natural languages because of their resemblance to the "natural" spoken English
language. Instead of being forced to key correct commands and data names in correct order, a
manager tells the computer what to do by keying in their own words.

Choosing a Language

In a work environment, the manager may decide that everyone in the project will use a
certain language.

We may need to use a certain language, particularly in a business environment, based on


the need to interface with other programs. If two programs are to work together, it becomes
easy when they are written in the same language.

We may choose a language based on its suitability or criteria. For example, COBOL will be
the best option for a business program that handles large files.

If a program is to be run on different computers, it must be written in a language that is


portable and suitable on each type of computer, so that the program needs to be written only
once.

We may be limited by the availability of languages. Not all languages are available on all
computers and in all installations.

The language may be limited to the expertise of a programmer. The program may have to be
written in a language that the available programmer knows.

Major Programming Languages are FORTRAN (a scientific language), COBOL (a business


language), BASIC (simple language used for education and business), Pascal (education), Ada
(military), and C (general purposed), C, C++, Java, and Javascript.
Please refer the link below to know more about programming.
http://homepage.cs.uri.edu/faculty/wolfe/book/Readings/Reading13.htm