Download as pdf or txt
Download as pdf or txt
You are on page 1of 27

Computer Programming

Mohammad Rokonuzzaman
26.10.2016
EEE-313

What is a computer???
A general purpose machine that can perform
any computational task

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Computer

I can perform any


computational task.
Just give me a right sent of
instructions.

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Computer

Program

A set of instruction
to perform a task

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Program
System programs.- Manages hardware resources
Application program- Manages applications such as word,
web browser et.

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Program

If any of the program can not perform the task you want, then
you can write your own program.

University of Asia Pacific


Department of Electrical
and Electronic Engineering
We will learn in this course

Writing and executing your own program


Program

A program is set of instructions / sequence that you would


give to the computer and the computer will execute it for you.

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Program

Now
What language should I use to give those instructions?

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Before that

We need to know how computer works

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Binary System

Computer only understands binary number, 0 or 1

But why.

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Binary System

Computer is an electrical device and its really easy to crate the


logic of 0 or 1 in an electrical circuit.

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Binary System

1- Something that exists


0 Something doesnt exist

1- some condition is true


0- some condition is false

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Binary System

A binary digit is called a Bit

Each bit can either be 0 or 1

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Binary system

1 2 3

If we have 3 bits, how many possible combinations we


have ?
Binary System

The core part of the computer that


understand and execute the instruction is
called a CPU.

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Binary System

Each instruction to the CPU has


to be a pattern of bits 0 and 1

But it can be random set of 0s and 1s

It has to follow a certain format.

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Programming Language

Low level language- Machine language, Assembly


High level language C, C++, JAVA

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Example - Machine language
Add two number 4 and 5

ADD Number 1 Number 2

Opcode Operand 1 Operand 2

ADD -0001
0001 00000100 00000101 SUB - 0010
COMP- 0101

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Example - Machine language
Add two number 4 and 5

ADD 04, 05

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Example - C language
Add two number 4 and 5

int sum;
sum = 4 +5 ;

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Programming Language

But CPU only understands machine language.

How does it handle assembly or c language ?

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Programming Language

Assembly Language

Assembler

Machine language

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Binary System

Compiler

Machine language

University of Asia Pacific


Department of Electrical
and Electronic Engineering
High level language
Two types:
Compiled languages : C , C++

Interpreted languages : Python


C

High level language

Need compilation

University of Asia Pacific


Department of Electrical
and Electronic Engineering
Why C ?

Easy to learn
It can be used to write any complex code.
Efficient and fast.
Portability : Program written in one computer can
run in another computer with little or no notification

University of Asia Pacific


Department of Electrical
and Electronic Engineering

You might also like