computer and programming

14
What is Computer And Programming ?

Upload: mahsachenari

Post on 12-Jul-2015

214 views

Category:

Devices & Hardware


6 download

TRANSCRIPT

Page 1: Computer and Programming

What is Computer And

Programming ?

Page 2: Computer and Programming

Computer is an electronic device for storing and

processing data, typically in binary form, which is

programmed to do such a wide variety of things .

The physical devices that a computer is made of are

named as computer’s hardware and the programs that are

programmed by programmers are called as software .

A program stores in main memory which is called as RAM

as long as it is running. And by turning the computer off ,

the content of RAM is erased.

Secondary storage is a type of memory that can hold data

for long periods of time ,even when no power is connected

to the computer.

Page 3: Computer and Programming

What is a Program?

A program is a set of instructions which is related to software

of a computer that a follows it to perform a task.

Page 4: Computer and Programming

Why do we program a

computer?

Page 5: Computer and Programming

Programming helps you understand computers. The

computer is only a tool. If you learn how to write simple

programs, you will gain more knowledge about how a

computer works.

Writing a few simple programs increases your confidence

level. Many people find great personal satisfaction in

creating a set of instructions that solve a problem.

Learning programming lets you find out quickly whether

you like programming and whether you have the analytical

turn of mind programmers need. Even if you decide that

programming is not for you, understanding the process

certainly will increase your appreciation of what

programmers and computers can do.

Page 6: Computer and Programming

A computer’s memory is divided into tiny storage locations

known as bytes which each byte includes eight smaller

parts named bits. Each byte is only enough to store a

letter of the alphabet or a small number.

Each character or number in a byte is shown by a

computer structure , including 0 and 1, like 10011100. If

the number is more longer than the capacity of a byte we

use 2 bytes (18bits) for it .

Page 7: Computer and Programming

How do we program?

Page 8: Computer and Programming

As I mentioned before a computer is programmed to run a

task .

There are different languages for programming a

computer , and choosing one of these languages depends

on demand like C, C++ , Java . . .

Programing is a bunch of codes which are written in a

specific programming language by a programmer .

The statements that are written by a programmer in a

high-level language are called source code or simply

code.

Structured programming requires that programmers break

program structure into small pieces of code that are easily

understood.

Page 9: Computer and Programming

Categories of Programing

language

Page 10: Computer and Programming

Low-Level

Low-Level ( Machine Language)

Computer understand only a language that is known as

“machine language”.

It consists of set of instructions in form of 1 and 0.

It is difficult for human to read and write machine

language.

Page 11: Computer and Programming

High-Level language

High level computer languages give formats close to

English language and the purpose of developing .

It helps people to write a program easily .

High level languages are basically symbolic languages

that use English words and mathematical symbols rather

than mnemonic codes.

Page 12: Computer and Programming

Compilers and Interpreters

Because the CPU understands only machine language

instructions, programs that are written in a language

depends on human language ( high-level language ) must

be translated into machine language.

Depending on the language that a program has been

written in , the programmer will use a complier or

interpreter to make the translation .

A compiler is a program that translate a high-level

language program into a separate machine language

program.

Page 13: Computer and Programming

How a program works?Scientists mention CPU as “computer’s brain” because they think CPU is smart. But CPU is an electronic device that is designed to do specific things. In particular ,the CPU is designed to perform operations . Such as ,

- Reading a piece of data from main memory

- Adding two numbers

- Moving a piece of data from one memory location to another

- Determining whether one value is equal to another value

The CPU performs simple operations on pieces of data. The CPU does nothing on its own. It has to be told what to do and that’s the purpose of a program.

Page 14: Computer and Programming

Fetch-Decode-Execute

cycleWhen a CPU executes the instructions in a program, it is

engaged in a process that is known as the fetch-decode-

execute cycle . This cycle, Which consists of three steps, is

repeated for each instruction in the program.

Fetch: a program is a long sequence of machine language

instructions. The first step of the cycle is to fetch, or read

the next instruction from memory into the CPU.

Decode: a machine language instruction is a binary

number that represents a command that tells the CPU to

perform an operation .

Execute: the last step in the cycle is to execute , or

perform, the operation.