Lecture02 by Asma

You might also like

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

CS 114-Fundamentals of Programming

Introduction
Asma Majeed

1
Computer Architecture
Agenda
Computer Programming
To be followed in today’s lecture

Motivation

Introduction to C

Features of C language

2
The Computer

Basic structure of a Computer in terms of


its main components

3
Central Processing Unit

Performs the actual processing of data

Data it processes is obtained, via the system bus, from the main memory

Results from the CPU are then sent back to main memory via the system bus

Controls and co-ordinates the operation of the other major components

4
Memory
• Memory of a computer
• Program instructions, data values, and the intermediate results
of calculations
• Information in memory is encoded in fixed size cells called bytes
• Byte can hold a small amount of information, such as a single character
or a numeric value between 0 and 255

5
Central Processing Unit
• CPU has two main components
• The Control Unit
• The fetching of instructions from the main memory and the subsequent
execution of these instructions
• Control of input and output devices and the passing of data to the
Arithmetic/Logical Unit for computation
• The Arithmetic/Logical Unit (ALU)
• Carries out arithmetic operations on integer (whole number) and real (with a
decimal point) operands
• Can also perform simple logical tests for equality and greater than and less than
between operands

6
Memory
• Two main categories of memory
• Main Memory
• Working memory of the CPU, with fast access and limited numbers of bytes being
transferred
• External memory
• For the long term storage of information
• Data from external memory will be transferred to the main
memory before the CPU can operate on it

7
Input/Output Devices

Most common input devices used by the


computer are the keyboard and the mouse

Most common output device are monitors


and printers

8
The System Bus
• All communication between the individual major components is
via the system bus
• A cable which is capable of carrying signals representing data
from one place to another
• Data from memory to a printer will be sent via the system bus.
• Control signals that are necessary to access memory and to
activate the printer are also sent by the CPU via the system bus

9
Information Representation
• Information inside the computer and on external storage
devices is represented in a form related to the Binary number
system
• Information on external memory is organized into files
• File could hold the text of a document, a computer program, a
set of experimental results etc

10
The Execution Cycle
• When a computer obeys the instructions in a program it is said
to be running or executing the program
• Computer can execute a computer program that is resident in
memory
• Program must occupy a set of consecutive bytes in memory and
must be written in the internal machine language for the
computer

11
What is Programming?

Program A set of instructions to be carried out by a


computer.

Program The act of carrying out the instructions


Execution contained in a program.
A systematic set of rules used to describe
Programming computations in a format that is editable by
Language humans.
Programming Languages

Machine Languages
Assembly Languages
0s and 1s
High Level Languages
Machine dependent Low level language
Architecture Independent
dependent e.g. C, C++, C#, .Net,
Java etc

13
Skills you’ll learn

Become familiar with programming

Sharpen your mathematical and analytical skills

Start “thinking algorithmically”

14
Take this course if you
like solving tricky problems

like building things

are curious about how Facebook, Google, etc work

have never written a computer program before

Think "computers and robots are going to take over the


world. I want to befriend them so that my life will be spared."

15
Fields of Computer Science
Few Examples

• Graphics • Machine Learning


• Computer Vision • Data Mining
• Artificial Intelligence • Natural Language
• Robotics • Processing User Interfaces

16
We will be studying a programming language called C.
Introduction to C

C is a general purpose imperative (procedural)


programming language designed by Dennis
Ritchie between 1969 and 1973 at AT&T Bell Labs.

We can call C “mother” of many modern


languages like c++, C#, Java etc…

18
Why C?
• As a middle level language,
• C combines the features of both high level and low level languages.
• It can be used for low-level programming
• such as scripting for drivers and kernels
• provide low-level access to memory
• It also supports functions of high level programming languages
• such as scripting for software applications etc.
• encourage cross-platform programming
• Relatively simple
• facilitates structured programming
• platform independent (Linux, Mac, Windows. . . )
• widely used
Strengths and Features
low-level a c c e s s to
memory

Mid Level cross-platform

structured platform
programming independent

relatively simple Widely used

Modularity

20
Home Assignment
Read Chapter 1 of the Text book
for further theoretical
knowledge about Programming
(in Particular C)

21

You might also like