Basic Computer Programming
By Tadesse M (MSc).
Programming
What is computer Programming?
Programming is the process of creating a set of direction
that tell a computer how to perform a task.
Is “Instruct the computer”: this basically means that you
provide the computer a set of instructions that are written in a
language that the computer can understand.
The instructions could be of various types. For example:
Adding 2 numbers,
Rounding off a number, etc.
Programming can be done using a variety of computer
programming languages.
What is computer Languages
A computer language is a method of communication
with a computer.
Computer programming language, any of various
languages for expressing a set of detailed instructions
for a digital computer.
Is a communication language by which a human can
specify an executable problem solution to a computer.
, Example C ++, JavaScript, Python, and etc
Why do we need to learn computer programming?
Computer programming is critical if one wants to know
how to make the computer perform a task.
1. You Can Create Anything You Want
The computer programming gives you the ability to
digitize your ideas.
It help us to simplify our life
We can get the power to control every thing
2. Enhanced problem solving skills
Knowledge of computer languages enhances
mathematical and logical reasoning and can be learned
surprisingly quickly.
These deduction skills will help you in all areas of your
life, like making decisions and solving complex
problems.
3, Opportunities for innovation
With more than 4 billion users on the internet, the
application of computer coding is more important
than ever. And, the computer science field attracts
some of the most talented minds around the world.
Graduates from programming or computer science
courses secure rewarding and unique career
opportunities in various fields, like environment,
medicine, gaming, business operations and finance.
4, Earn a Higher Salary
Pay is probably the biggest advantage of working as a
computer programmer. Computer programmers, who
write computer code that enables a computer to perform
certain tasks, work in almost every industry you can
imagine, including the engineering, educational and
medical fields. According to the Indeed website, starting
salaries in the computer programming field in January
2012 range from $59,000 to $112,000 per year. Some
companies that do not employ computer programmers
are willing to contract their services for as much as
$100 to $400 per hour, according to Ask IT Career
Coach, a career informational website.
5. Does Not need large space
Computer programming does not require office
space to be leased or bound to an etched-in-stone
work schedule.
computer programming can be done from
anywhere, you can bring your desktop computer,
you can access the internet and you can complete
the work from home.
What is a programmer ?
A programmer is an individual that writes/creates
computer software or applications by giving the
computer specific programming instructions.
Most programmers have a broad computing and
coding background across multiple programming
languages and platforms, including Structured Query
Language (SQL), Perl, Extensible Markup Language
(XML), PHP, HTML, C, C++ and Java.
A programmer also may specialize in one or more
computing fields, like database, security or
software/firmware/mobile/Web development.
These individuals are instrumental to the development
of computer technology and the field of computing.
What skills do we need to be a programmer?
1, Problem-Solving:
One of the major skills that a programmer must
possess is problem-solving skills.
Not only should a programmer be unafraid of
problems and in fact, face them head on, the
programmer should also be able to find problems to
solve.
a programmer should be able to come out with
technological ways of solving basic human
problems.
This is why good programmers have to be great or
at least, possess basic proficiency in mathematics,
geometrics or statistics.
2, Time Management:
As a programmer, you have to be reliable and trusted
to get the job done as quickly as possible.
You have to be trusted to meet deadlines.
Even if you come highly recommended because of
the technical skill, employers will expect that you
imbibe good time management skills.
3, Good Communication Skills:
Programmers have to be able to communicate
effectively with both the computer and to people.
You shouldn’t look down on their lack of
understanding and should instead explain to them
calmly. Also, because people are going to be dealing
with the programs you create, you need to make them
user-friendly. At least, let the user, who want to use a
website like www.betensured.com, who has a basic
knowledge of technology be able to navigate through
the programs.
4, Quick Learning Skills:
One skill that is common with most programmers is
their ability to self-learn and learn quickly.
They do not away from new technologies or programs
but instead sit with it until they learn how it all came
together and they can even find new ways to work it to
provide better technologies.
As a programmer, you have to be ready to self-learn and
even learn every day because new technologies are
released every other day.
5, Coding Language skill
You can’t be a programmer without becoming proficient
in at least one coding language (for example, C ++,
JavaScript or Ruby on Rails).
6, Algorithm Development:
skill of coming up with sequence of simple and human
understandable set of instructions showing the step of
solving the problem. Those set of steps should not be
dependent on any programming language or machine
8, Programming Language Rules
In every programming Language there are sets of
rules that govern the symbols used in a
programming language.
These set of rules determine how the programmer
can make the computer hardware to perform a
specific operation.
These sets of rules are called syntax.
Generations of programming language.
Programming languages are categorized into five
generations: (1st, 2nd, 3rd, 4th and 5th generation
languages)
These programming languages can also be categorized
into two broad categories: low level and high level
languages.
From the five categories of programming languages,
first and second generation languages are low level
languages and the rest are high level programming
languages.
The higher the level of a language, the easier it is to
understand and use by programmers.
Languages after the forth generation are refereed to as a
very high level languages.
First Generation (Machine languages, 1940’s):
Difficult to write applications with.
Dependent on machine languages of the specific computer
being used.
Machine languages allow the programmer to interact
directly with the hardware, and it can be executed by the
computer without the need for a translator.
Is more powerful in utilizing resources of the computer.
Gives power to the programmer.
They execute very quickly and use memory very
efficiently.
Second Generation (Assembly languages, early 1950’s):
Uses symbolic names for operations and storage
locations.
A system program called an assembler translates a
program.
Programs written in assembly language are not
portable. i.e., different computer architectures have their
own machine and assembly languages.
They are highly used in system software development.
Third Generation (High level languages, 1959’s to
1970’s):
Uses instructions and mathematicians were able to define
variables with statements such as Z = A + B
Such languages are much easier to use than assembly
language.
Programs written in high level languages need to be
translated into machine language in order to be executed.
The use of common words (reserved words) within
instructions makes them easier to learn.
All third generation programming languages are
procedural languages.
In procedural languages, the programmer is expected to
specify what is required and how to perform it.
Fourth Generation (since late 1970’s):
Have a simple, English like syntax rules; commonly used
to access databases.
Forth generation languages are non-procedural languages.
The non-procedural method is easier to write, but you have
less control over how each task is actually performed.
In non-procedural languages the programmer is not
required to write traditional programming logic.
Programmers concentrate on defining the input and output
rather than the program steps required.
Cont..
Forth generation languages have a minimum
number of syntax rules. This saves time and free
professional programmers for more complex tasks.
Some examples of 4GL are structured query
languages (SQL), report generators, application
generators and graphics languages.
Fifth Generation (1990’s):
These are used in artificial intelligence (AI) and expert
systems; also used for accessing databases.
5GLs are “natural” languages whose instruction closely
resembles human speech. E.g. “get me Jone Brown’s sales
figure for the 1997 financial year”.
5GLs require very powerful hardware and software
because of the complexity involved in interpreting
commands in human language.
Overview of Computers and Computer Organization.
Regardless of differences in physical appearance,
virtually every computer may be envisioned as being
divided into six logical units or sections:
Input Unit: it obtains information from various input
devices and places this information at the disposal of the
other units so that the information may be processed or
stored.
Output Unit: it takes information that has been
processed by the computer and places it on various
output devices to make the information available for use
Memory unit: it retains information that has been entered
through the input unit, so the information may be made
immediately available for processing when it is needed. The
memory unit also retains processed information until that
information can be placed on output devices by the output
unit.
Central Processing Unit (CPU): it is the computer’s
coordinator and is responsible for supervising the
operations of the other sections. CPU tells the input unit
when information should be read into memory, tells ALU
when information from the memory should be used in
calculation and tells output unit when to send information
from the memory to certain output devices.
Count..
Arithmetic and Logic unit: is a part found inside the
Central Processing Unit and is responsible for
performing calculations such as addition, subtraction,
multiplication and division. It also performs
comparisons.
Secondary Storage device: Programs or data used by
other units normally are placed on secondary storage
devices (such as disks) until they are needed, possibly
hours, days, months, or even years later.
The evolution of Operating Systems
The operating system acts as the controller of all the
above-mentioned resources and assigns them with
specific programs executed to perform the task.
Hence, the operating system is a resource manager that
handles the resource as a user view and system view.
The evolution of the operating system is marked from
the programming of punch cards to training machines
to speak and interpret any language.
Major Programming Paradigms
The major land marks in the programming world
are the different kinds of features or properties
observed in the development of programming
languages.
Among these the following are worth mentioning
Procedural, Structured and Object Oriented
Programming Paradigms
1, Procedural Programming
Procedural programming is a programming paradigm
based upon the concept of procedure call. Procedural
programming is often a better choice than simple
sequential programming in many situations.
It moderate complexity situation or which require
significant ease of maintainability.
Possible benefits: the ability to re-use the same code
(function or procedure) at different places, an easier way
to keep track of program flow than a collection of “GO
TO” or “JUMP” statements
2, Structured Programming.
Process of writing a program in small, independent parts.
This makes it easier to control a program's development
and to design and test its individual component parts.
Structured programs are built up from units called
modules, which normally correspond to single
procedures or functions.
Can be seen as a subset or sub discipline of procedural
programming. It is most famous for removing or reducing
reliance on the GO TO statement.
3, Object-Oriented Programming.
The idea behind OOP is that, a computer program
is composed of a collection of individual units, or
objects as opposed to traditional view in which a
program is a list of instructions to the computer.
Object-oriented programming is claimed to give
more flexibility, easing changes to programs. The
OOP approach is often simpler to develop and
maintain.
What is a software Engineer?
Software engineer is defined as a process of
analyzing user requirements and then designing,
building, and testing software application which
will satisfy those requirements.
Software engineering, which involves, 'the practical
application of scientific knowledge to the creative
design and building of computer programs.
Problem solving process and software engineering.
What is the software development life cycle?
SDLC or the Software Development Life Cycle is a
process that produces software with the highest quality
and lowest cost in the shortest time possible.
SDLC provides a well-structured flow of phases that
help an organization to quickly produce high-quality
software which is well-tested and ready for production
use.
Popular SDLC models include the waterfall model,
spiral model, and Agile model.
The Problem that face during Develop Software
1 – Not Understanding the User
In software development, user centricity isn’t an option
it’s a priority. Of course, to make any software user
centric, you have to know what users want.
Your users may have opinions about how a product
should work.
These opinions may differ from those of your
development team.
2, Communication Problem
As a new programmer, you probably don’t know
anyone in your new workplace. Sure, maybe you know
the colleague who told you about the job opening, but
not the members of your team or the project manager
you will be working with. And if you don’t know
them, you might hesitate to talk to them about
anything, from code-related issues to getting to know
the corporate pecking order.
3, Time Estimation Problem
Maybe you didn’t know how to make a good estimate.
Or maybe you gave an estimate, but didn’t stick to it. In
the end, you couldn’t keep up with the rest of the team
and your project went over schedule.
Estimates are important in software development. They
can be a basis for price quotes and project schedules.
Schedule delays cause problems and may compromise
trust.
4, Security Threats
Data is a valuable commodity. And some people are
willing to pay a lot for it, including your client’s
competitors looking to pry into a top secret project (like
a marketing or enterprise software) that you might be
working on.
Your clients rely on you to keep their information safe
from these threats. That’s a lot of pressure.
Unfortunately, beginners often overlook
security loopholes in their code and don’t become
5, Limited infrastructure/resources
Another challenge faced by majority of software
development companies is a lack of resources or IT
infrastructure to execute projects effectively.
This could mean a lack of high performance
software development tools, powerful computing
platforms, inefficient data storage architectures or
improper networks and connectivity.
6, Rapid technology advancement
Every technology advancement is a blessing for the IT
industry. But at the same time, technology evolving at a
phenomenal rate leads to an added pressure for
software development professionals to leverage these
upcoming technology trends in software product
development to gain a cutting edge over competitors
and stand out in the market.
Problem solving process
1, Identify the Current Problems
“What are the current problems?” This stage of the
SDLC means getting input from all stakeholders,
including customers, salespeople, industry experts, and
programmers.
Learn the strengths and weaknesses of the current
system with improvement as the goal.
2, Gathering information
Asking other for new thing leads to “solving” problems
with fully understanding them. That’s to say any of these
resources—Stack Overflow, tutorials,Examples include:
Googling Stack Overflow as a first step.
Copying and pasting code—whether from Stack
Overflow, a tutorial, or elsewhere in your codebase—
without understanding what it does.
3. Plan
“What do we want?”.
In this stage of the SDLC, the team determines the cost
and resources required for implementing the analyzed
requirements.
It also details the risks involved and provides sub-
plans for softening those risks.
In other words, the team should determine the
feasibility of the project and how they can implement
the project successfully with the lowest risk in mind.
4. Try potential solutions
Try something. It doesn’t have to be perfect. If you see
anything change as a result, that’s a success. You’ll
improve on it soon. Then keep trying things until
you’ve made substantial progress on the problem.
If you’re in unfamiliar territory, it can help to break
down the “solution” into very small increments, and
try them out piece by piece. Print your data to the
console before you worry about how it’ll be rendered.
5. Test your solution
Often we do this by hand: load a web page and check
that it contains all the elements we expect it to render.
Try replicating the conditions that led to a bug, and
confirm that the bug no longer happens. Try using the
feature we added in a few different ways and see what
happens.
Another way we do this is with automated tests.
Adding a test that asserts a feature works as predicted
or a bug no longer occurs helps prevent unexpected
problems down the line.
6, Implement
Software implementation refers to the process of
adopting and integrating a software application
into a business workflow.
Implementation of new tools and software into an
enterprise can be complex, depending on the size
of the organization and the software. Once the
solution is chosen, implementation can begin.
Modeling a programs logic using flow chart
A flowchart is a type of diagram that represents a
workflow or process. A flowchart can also be defined
as a diagrammatic representation of an algorithm, a
step-by-step approach to solving a task. The flowchart
shows the steps as boxes of various kinds, and their
order by connecting the boxes with arrows.
A flowchart is a diagram that depicts a process,
system or computer algorithm. They are widely used in
multiple fields to document, study, plan, improve and
communicate often complex processes in clear, easy-
to-understand diagrams.
Flowchart Symbols
Different flowchart shapes have different conventional
meanings. The meanings of some of the more common
shapes are as follows:
Terminator
The terminator symbol represents the starting or ending
point of the system.
Process
A box indicates some particular operation.
Document
This represents a printout, such as a document or a report
Decision
A diamond represents a decision or branching point.
Lines coming out from the diamond indicates different
possible situations, leading to different sub-processes.
Find the largest among three different numbers
entered by the user
Chapter 2
C++