Introduction to Computer Programming- CSC141
Muhammad Usman Yaseen
Recommended Books:
• Text Book / Essential Reading:
• “Introduction to computers”, Peter Norton, 4th
Edition
• A book on ‘C’ by Kelly
• Reference Books / Literature:
• Computer Today, Donald H Sanders, 3rd Edition
• Computers, H.L Capron 6th Edition
• Let us ‘C’ by Yashvant Kanethar
• Turbo c/c++ programming by Robert Lafore
Computer programming
• Humans are intelligent and computers are
dumb.
– Humans can think on their own, computers can’t.
– Humans know what to do, computers don’t.
• Computers need to know what to do.
– They rely on humans.
• Humans control computers
• Very simply, telling the computer what to do
is called computer programming!
Computer program…
• A computer needs instructions to perform
a task.
– It just can’t decide on its own… not at all!
– The instructions have to be
• Detailed
• Step by step
• Exact
• Accurate
• Complete
… computer program
• The set of step by step instructions following
which, a computer can perform the required
task, is known as a computer program.
– These instructions
• Are written by a human being, called a computer
programmer to
– Control the computer.
– Make use of the computer’s tremendous power to get the
job done.
• Computer programming can also be simply
defined as writing computer programs.
I/O…
• Recall that
– Every task to be done, problem to be solved
requires some input.
– The input need to be processed in a certain
manner.
– The processing generates some kind of
results that solve the problem.
• So input, processing, output is the
simplest way to solve any problem.
… I/O
• It all starts with the output.
– Getting the output is the objective.
– Feeding the input is a requirement.
– Processing the input to get to the output is
what needs to be done.
• This is where you solve the problem!
Some examples…
• Problem: a glass full of orange juice is
needed.
• Input: a couple of oranges.
• Processing:
1. Cut the oranges
2. Squeeze the oranges
3. Catch the juice flowing out of the oranges into a
glass.
• Output: a glass full of orange juice… drink it!
… some examples…
• Problem: shirt needs to be pressed.
• Input: a wrinkled shirt.
• Processing:
1. Heat the iron.
2. Adjust the shirt on a flat surface.
3. Press the shirt with the hot iron until the
wrinkles go away.
• Output: a wrinkle-free pressed shirt.
Computer’s I/O…
• Computers also rely on input, processing
and output.
• You need to get something done from the
computer, you need the output.
• The computer needs relevant input to get
to the output.
• It gets the input, processes it, and
generates the output.
… computer’s I/O
Computer
Computer program
• You want the computer to do something,
you want the output.
• You have the required input to get the
output from.
• You need the computer to process the
input and give the output, but
– The computer doesn’t know what to do…
remember?
… computer program…
• So you need to tell the computer how to
process the input to get the output.
• You will tell it through detailed step by step
instructions.
• Step by step instructions are a computer
program.
… computer program…
• So you instruct the computer, step by step,
telling it what to do, how to do… to
produce the output you need through the
input you feed!
• Thus, a computer program instructs the
computer to
– Accept the input through input devices.
– Process the input and generate the output.
– Give the output back through output devices.
… computer program…
• Everything that happens inside a computer is
under its processor’s control.
• To make the computer do something, you
need to instruct the processor.
• So a computer program instructs the
computer’s processor to perform the task.
• A computer program has instructions written in
it, which a computer can understand.
• Computer program = computer software.
… computer program
• Everything that a computer does is
governed by a computer program.
• There are different programs/software that
make the computer perform different
activities.
• Examples of programs
– Microsoft windows
– Microsoft word
– Adobe Photoshop
– etc
Programming language…
• You communicate with humans in a
language they understand.
• You need to communicate with a computer
in a language it understands.
• The language a computer understands is
called Machine Language.
– It’s extremely complicated.
• So complicated that its not understandable for
humans.
… programming language…
• To communicate with somebody who doesn’t
understand your language, you need to
translate your language into his language.
• To communicate with a computer, you need
to
– Write instructions in a language that you
understand.
– Translate those instructions into machine
language that the computer understands.
… programming language
• A language which you use to write computer
programs is called programming language.
– The language you write programs in has to be
one that you can understand.
• Programming languages that humans can
understand are known as high level languages.
– The computer only understands machine
language.
– You need to write programs in high level
languages and convert/translate them into
machine language.
Coding
• A computer program you write in a high
level language is also referred to as
Source Code.
• Programming is also referred to as
Coding.
• A person who writes computer programs is
“sometimes” referred to as a Coder.
– The word Programmer is more appropriate
and more common.
Translator…
• Microsoft Word is a computer program
which helps you compose text documents.
• Microsoft Paint is another program which
helps you draw images.
• Similarly, there are programs you use to
translate programs you write in high level
languages into corresponding machine
language.
… translator
• A program that translates the entire source
code into its machine language equivalent
in one go is called a Compiler.
– Compiler is said to “compile” the source code.
• A program that translates the source code
into its machine language instruction by
instruction is called an Interpreter.
– Interpreter translates one instruction at a time.