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

CS150 - Unit 1 - What Is Programming

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

CS150 - Unit 1 - What Is Programming

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

Unit One

What Is Programming

Computer programming (often shortened to programming) is a process that starts from an


original formulation of a computing problem to executable computer programs. The purpose of
programming is to find a sequence of instructions that will automate performing a specific task
or solving a given problem. The process of programming thus often requires expertise in many
different subjects, including knowledge of the application domain, specialized algorithms
and formal logic.
Related tasks include testing, debugging, and maintaining the source code, implementation of the
build system, and management of derived artifacts such as machine code of computer programs.
These might be considered part of the programming process, but often the term software
development is used for this larger process with the term "programming", "implementation", or
"coding" reserved for the actual writing of source code.

Computers are so widespread in our society because they have three advantages over us humans.
First, computers can store huge amounts of information. Second, they can recall that information
quickly and accurately. Third, computers can perform calculations with lightning speed and
perfect accuracy.

The advantages that computers have over us even extend to thinking sports like chess. In 1997,
the computer Deep Blue beat the world chess champion, Garry Kasparov, in a chess match. In
2003, Kasparov was out for revenge against another computer, Deep Junior, but only drew the
match. Kasparov, while perhaps the best chess player ever, is only human, and therefore no
match for the computer’s ability to calculate and remember prior games.

However, we have one very significant advantage over computers. We think on our own, while
computers don’t, at least not yet anyway. Indeed, computers fundamentally are far more brawn
than brain. A computer cannot do anything without step-by-step instructions from us telling it
what to do. These instructions are called a computer program, and of course are written by a
human, namely a computer programmer. Computer programs enable us to harness the
computer’s tremendous power.

Programming is problem-solving
Essentially, a program tells the computer how to solve a specific problem. Because the world is
full of problems, the number and variety of programs that people can write for computers is
practically endless.
But to tell a computer how to solve one big problem, you usually must tell the computer how to
solve a bunch of little problems that make up the bigger problem. If you want to make your own
video game, for example, you need to solve some of the following problems:
 Determine how far to move a cartoon figure (such as a car, a spaceship, or a man) on-screen
as the user moves a joystick.
 Detect whether the cartoon figure bumps into a wall, falls off a cliff, or runs into another
cartoon figure on-screen.
 Make sure that the cartoon figure doesn't make any illegal moves, such as walking through a
wall.
 Draw the terrain surrounding the cartoon figure and make sure that if the cartoon figure
walks behind an object such as a tree, the tree realistically blocks the figure from sight.
 Determine whether bullets that another cartoon figure fires are hitting the player's cartoon
figure. If so, determine the amount of damage, how it affects the movement of the damaged
cartoon figure, and how the damage appears on-screen.
The simpler the problem is that you need to solve, the more easily you can write a program that
tells the computer how to work. A program that displays a simple Ping-Pong game with two
stick paddles and a ball is much easier to write than a program that displays World War II fighter
airplanes firing machine guns and dropping bombs on moving tanks while dodging anti-aircraft
fire.

What It takes to Program


Programming really isn't that difficult or mysterious. If you can write step-by-step instructions
directing someone to your house, you can write a program.
The hardest part about programming is identifying all the little problems that make up the big
problem that you're trying to solve. Because computers are completely stupid, you need to tell
them how to do everything.
If you want to tell your friend how to prepare a meal say, nshima, you don’t have to tell them all
the details. For the computer however these may not be clear. You need to specify how much
Millie meal, how big should the pot be, how long should the water boil, and many other specific
and precise details.
You need to tell computers how to do everything, which can make giving them instructions as
aggravating and frustrating as telling children what to do. Unless you specify everything that you
want the computer to do and exactly how to do it, the computer on its own will not know how to
do what you want it to do.
Data Representation In The Computer
Let’s take a bit of time to talk about how data is represented in a computer. Your computer
successfully creates the illusion that it contains photographs, letters, songs, and movies. All it
really contains is bits, lots of them, patterned in ways you can't see. Your computer was
designed to store just bits - all the files and folders and different kinds of data are illusions
created by computer programmers.
Basically, computer instructions perform operations on groups of bits. A bit is either on or off,
like a lightbulb. Figure 1.1 shows an open switch and a lightbulb that is off - just like a transistor
in a computer represents a bit with the value: zero. The figure on the right shows the switch in
the closed position and the lightbulb is on, again just like a transistor in a computer representing
a bit with the value: one.

Light bulb off Light bulb on


Figure 1.1 A light bulb-synonymous to representation in computers

A microprocessor, which is the heart of a computer, is very primitive but very fast. It takes
groups of bits and moves around their contents, adds pairs of groups of bits together, subtracts
one group of bits from another, compares a pair of groups, etc. Inside a microprocessor, at a very
low level, everything is simply a bunch of switches, also known as bits - things that are either on
or off!

Symbols As Bits - Ascii Characters


Numbers are simply groups of bits. What other objects will the computer's instructions
manipulate? How about the symbols that make up an alphabet?
It should come as no surprise that symbols that make up alphabets are just numbers, groups of
bits, too. Let's walk through a couple of examples, entries in the table. Here are some
characters, their decimal value and their binary value which is then transformed into an octal
number.

Uppercase 'A' = decimal 65 = binary 01000001 = 01 000 001 = octal 101


Uppercase 'Z' = decimal 90 = binary 01011010 = 01 011 010 = octal 132
The digit '1' = decimal 49 = binary 00110001 = 00 110 001 = octal 061
Table 1.0 ASCII character set, just enough to give you a flavor of its organization.

ASCII in in in in
Character Binary Octal Decimal Hex
Space 00100000 040 32 20
( 00101000 050 40 28
) 00101001 051 41 29
* 00101010 052 42 2A
0 00110000 060 48 30
1 00110001 061 49 31
2 00110010 062 50 32
9 00111001 071 57 39
A 01000001 101 65 41
B 01000010 102 66 42
C 01000011 103 67 43
Z 01011010 132 90 5A
A 01100001 141 97 61
B 01100010 142 98 62
C 01100011 143 99 63
Z 01111010 172 122 7A

This might look a bit strange but the main point you have to pick up from here is that the computer does
not store data as we do using different characters, rather everything is stored as a bit. You will learn more
about this fact in computer Architecture.

There is a difference between the language that a computer understands and the languages that we use as
humans. So then the question is in which language can we speak to the computer so that it can understand
us?

How do computer languages differ from human languages?


How can we bridge the gap between human languages and
computer language?
UNIT SUMMARY

 A program is a set of instructions used by the computer to carry out a task. The
instructions must be precise and specific.
 Programming is the art of writing computer programs
 Programming is problem solving
 Computers do not understand the languages that used by humans. They use 0s and 1s to
represent data.
 Programming is done using a programming language

EXERCISE

Answer the following questions

1. Explain what programming is.


2. How does instructing a person differ from instructing a computer?
3. Elaborate three (3) reasons why programs are developed.
4. Explain the role that programming plays in the business world.

You might also like