66
CENG 230 Introduction to C Programming Week 1 – Overview and introduction Sinan Kalkan Some slides/content are borrowed from Tansel Dokeroglu, Nihan Kesim Cicekli.

CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Embed Size (px)

Citation preview

Page 1: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

CENG 230Introduction to C Programming

Week 1 – Overview and introduction

Sinan Kalkan

Some slides/content are borrowed from Tansel Dokeroglu, Nihan Kesim Cicekli.

Page 2: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Syllabus

CENG 230 - Spring 2015 Sinan Kalkan 2

Page 3: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

How to study?

• Follow the lectures and the labs

• Read the textbook on a weekly basis

• Get your hands dirty• Do the exercises in front of the computer

CENG 230 - Spring 2015 Sinan Kalkan 3

Page 4: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Appointment

• No office hours. Make an appointment.

• Via email: [email protected]

• Office: Room B207,

Department of Computer Engineering

• WWW: • http://kovan.ceng.metu.edu.tr/~sinan/

CENG 230 - Spring 2015 Sinan Kalkan 4

Page 5: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Programming, computation, algorithm

CENG 230 - Spring 2015 Sinan Kalkan 5

Page 6: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Program, Programming

PROGRAM

IMPLEMENTED

CENG 230 - Spring 2015 Sinan Kalkan 6

Page 7: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

What is an algorithm?

An algorithm is a list that looks like

STEP 1: Do something

STEP 2: Do something

STEP 3: Do something

. .

. .

. .

STEP N: Stop, you are finished

CENG 230 - Spring 2015 Sinan Kalkan

From “Invitation to Computer Science”

7

Page 8: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

CENG 230 - Spring 2015 Sinan Kalkan

From “Invitation to Computer Science”

8

Page 9: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

A formal definition of algorithm

• “Starting from an initial state and initial input (perhaps empty), the instructions describe a

computation that, when executed, will proceed through a finite number of well-defined successive states, eventually producing "output" and terminating at a final ending state.”

CENG 230 - Spring 2015 Sinan Kalkan 9

Page 10: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Algorithms

• We use them all the time.

• Can you give examples?• Following directions

• Recording a DVD

• Adding two numbers

• Finding Greatest Common Divisor

• …

CENG 230 - Spring 2015 Sinan Kalkan

From “Invitation to Computer Science”

10

Page 11: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

An example algorithm

CENG 230 - Spring 2015 Sinan Kalkan

From “Invitation to Computer Science”

11

Page 12: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

“Computation”

• Digital vs. analog computation

• Sequential vs. parallel computation

• Batch vs. interactive computation

• Evolutionary, molecular, quantum computation

• “Physical computation” / “Digital Physics”• ‘The whole universe is itself a computation’

CENG 230 - Spring 2015 Sinan Kalkan 12

Page 13: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Computation in our brain

• Highly-connected network of neurons.

• How many neurons? • Approx. 1011 neurons and

1014 synapses.

• How do they transmit information?• Using nothing else than

charged molecules.

CENG 230 - Spring 2015 Sinan Kalkan 13

Page 14: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Computation in our brain (cont’d)

• Each neuron gets input and produces an output using an “activation function”

CENG 230 - Spring 2015 Sinan Kalkan 14

Page 15: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

DIGITAL COMPUTATION

CENG 230 - Spring 2015 Sinan Kalkan

Turing Machine Von Neumann Architecture

15

Page 16: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

But first some historical overview

CENG 230 - Spring 2015 Sinan Kalkan 16

Page 17: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

The Early Period: Up to 1940

• 3,000 years ago: Mathematics, logic, and numerical computation

• Important contributions made by the Greeks, Egyptians, Babylonians, Indians, Chinese, and Persians

• Cuneiform

• Stone “abacus”

• http://www.thocp.net/slideshow/0469.htm

Slide from “Introduction to Computing”CENG 230 - Spring 2015 Sinan Kalkan 17

Page 18: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

ABACUSEarly calculating devicesABACUS – 2700 BC (Mesopotamia)

http://www.computersciencelab.com/ComputerHistory/History.htmSlide from “Introduction to Computing”

CENG 230 - Spring 2015 Sinan Kalkan 18

Page 19: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

DaVinci• 1452-1519 Leonardo DaVinci sketched gear-driven

calculating machines but none were ever built.

http://www.computersciencelab.com/ComputerHistory/History.htm

Slide from “Introduction to Computing”CENG 230 - Spring 2015 Sinan Kalkan 19

Page 20: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Napier’s Bones

• 1614: Logarithms

• Invented by John Napier to simplify difficult mathematical computations

http://www.computersciencelab.com/ComputerHistory/History.htmSlide from “Introduction to Computing”

Napier’s Bones:

CENG 230 - Spring 2015 Sinan Kalkan 20

Page 21: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

• If you want to multiply 7 by 46785499:

CENG 230 - Spring 2015 Sinan Kalkan 21

Page 22: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Slide Rule (slipstick)“a mechanical analog computer”

Around 1622: First slide rule created

http://www.computersciencelab.com/ComputerHistory/History.htm

Slide from “Introduction to Computing”CENG 230 - Spring 2015 Sinan Kalkan 22

Page 23: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

The Pascaline: One of the Earliest Mechanical Calculators

Slide from “Introduction to Computing”CENG 230 - Spring 2015 Sinan Kalkan 23

Page 24: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

The Early Period: Up to 1940

Jacquard’s LoomAlso see http://www.computersciencelab.com/ComputerHistory/HistoryPt2.htm

Slide from “Introduction to Computing”CENG 230 - Spring 2015 Sinan Kalkan 24

Page 25: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Difference engine

http://www.youtube.com/watch?v=0anIyVGeWOI

Slide from “Introduction to Computing”CENG 230 - Spring 2015 Sinan Kalkan 25

Page 26: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Slide from “Introduction to Computing”CENG 230 - Spring 2015 Sinan Kalkan 26

Page 27: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Programming the ENIAC

Slide from “Introduction to Computing”CENG 230 - Spring 2015 Sinan Kalkan 27

Page 28: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

DIGITAL COMPUTATION

CENG 230 - Spring 2015 Sinan Kalkan

Turing Machine Von Neumann Architecture

28

Page 29: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

A computer

Devices

Gates

TransistorsCENG 230 - Spring 2015 Sinan Kalkan 29

Page 30: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Everything in a PC is Binary… well, almost …

CENG 230 - Spring 2015 Sinan Kalkan 30

Page 31: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

A transistor

This circuit functionsas a switch. In other words,based on the control voltage,the circuit either passes Vinto output or not.

CENG 230 - Spring 2015 Sinan Kalkan 31

Page 32: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Examples of transistors

Replica of the first transistor A set of transistors, depictingthe fast change in technology.

CENG 230 - Spring 2015 Sinan Kalkan 32

Page 33: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

A computer

Devices

Gates

TransistorsCENG 230 - Spring 2015 Sinan Kalkan 33

Page 34: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

NOT Gate

X

0

1

X

1

0X X

CENG 230 - Spring 2015 Sinan Kalkan 34

Page 35: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

AND gate

X

0

0

1

1

Y

0

1

0

1

X·Y

0

0

0

1

CENG 230 - Spring 2015 Sinan Kalkan 35

Page 36: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

OR Gate

X

0

0

1

1

Y

0

1

0

1

X+Y

0

1

1

1

CENG 230 - Spring 2015 Sinan Kalkan 36

Page 37: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

XOR Gate

X

0

0

1

1

Y

0

1

0

1

X⊖Y

0

1

1

0

CENG 230 - Spring 2015 Sinan Kalkan 37

Page 38: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

An example problem: Water Tank

Schematic

Representation

HI

0011

LO

0101

Pump

010x

Drain

001x

Tank level is OKLow level, pump more inHigh level, drain some outInputs cannot occur

Truth TableRepresentation

HI

LO

Pump

DrainCENG 230 - Spring 2015 Sinan Kalkan 38

Page 39: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Sinan Kalkan

The binary addition

Question (Binary notation) : 111010 + 11011 = ?

CENG 230 - Spring 2015 39

Page 40: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

1-bit full-adder

A 0 0 0 0 1 1 1 1

B 0 0 1 1 0 0 1 1

CI 0 1 0 1 0 1 0 1

S 0 1 1 0 1 0 0 1

CO 0 0 0 1 0 1 1 1

A B

CI

0

1

00 01 11 10

0

1

1

0

1

0

0

1

A B

CI

0

1

00 01 11 10

0

0

0

1

0

1

1

1

S

CO

0 0 1 1

+ 0 0 1 0

0 1 0 1

1

A

B

S

CinCo

CENG 230 - Spring 2015 Sinan Kalkan 40

Page 41: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

N-bit Adder

+

A3 B3

S3

+

A2 B2

S2

+

A1 B1

S1

+

A0 B0

S0C1C2C3

CENG 230 - Spring 2015 Sinan Kalkan 41

Page 42: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Representing data

CENG 230 - Spring 2015 Sinan Kalkan 42

Page 43: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Data Representation

• Based on 1s and 0s• So, everything is represented as a set of binary numbers

• We will now see how we can represent:• Integers: 3, 1234435, -12945 etc.

• Floating point numbers: 4.5, 124.3458, -1334.234 etc.

• Characters: /, &, +, -, A, a, ^, 1, etc.

• …

CENG 230 - Spring 2015 Sinan Kalkan 43

Page 44: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Sinan Kalkan

• Decimal numbering system• Base-10

• Each position is a power of 103052 = 3 x 103 + 0 x 102 + 5 x 101 + 2 x 100

• Binary numbering system• Base-2

• Uses ones and zeros

• Each position is a power of 21101 = 1 x 23 + 1 x 22 + 0 x 21 + 1 x 20

Binary Representation of Numeric Information

CENG 230 - Spring 2015 44

Page 45: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Decimal-to-binary Conversion

• Divide the number until zero:• 35 / 2 = 17x2 + 1

• 17 / 2 = 8x2 + 1

• 8 / 2 = 4x2 + 0

• 4 / 2 = 2x2 + 0

• 2 / 2 = 1x2 + 0

• Therefore, 35 has the binary representation: 100011

Sinan KalkanCENG 230 - Spring 2015 45

Page 46: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

IEEE 32bit Floating-Point Number Representation

• M x 2E

• Exponent (E): 8 bits • Add 127 to the exponent value before storing it• E can be 0 to 255 with 127 representing the real

zero.• Fraction (M - Mantissa): 23 bits• 2128 = 1.70141183 × 1038

CENG 230 - Spring 2015 Sinan Kalkan 46

Page 47: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

IEEE 32bit Floating-Point Number Representation• Example: 12.375• The digits before the dot:

• (12)10 (1100)2

• The digits after the dot: • 1st Way: 0.375 0x½ + 1x¼ + 1x1/8 011• 2nd Way: Multiply by 2 and get the integer part until 0:

• 0.375 x 2 = 0.750 = 0 + 0.750• 0.750 x 2 = 1.50 = 1 + 0.50• 0.50 x 2 = 1.0 = 1 + 0.0

• (12.375)10 = (1100.011)2

• NORMALIZE: (1100.011)2= (1.100011)2x23

• Exponent: 3, adding 127 to it, we get 1000 0010• Fraction: 100011• Then our number is: 0 10000010 10001100000000000000000

CENG 230 - Spring 2015 Sinan Kalkan 47

Page 48: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

• Characters are mapped onto binary numbers

• ASCII (American Standard Code for Information Interchange) code set

• Originally: 7 bits per character; 128 character codes

• Unicode code set

• 16 bits per character

• UTF-8 (UCS Transformation Format) code set.

• Variable number of 8-bits.

Binary Representation of Textual Information

CENG 230 - Spring 2015 Sinan Kalkan 48

Page 49: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Binary Representation of Textual Information (cont’d)Decimal Binary Val.

48 00110000 0

49 00110001 1

50 00110010 2

51 00110011 3

52 00110100 4

53 00110101 5

54 00110110 6

55 00110111 7

56 00111000 8

57 00111001 9

58 00111010 :

59 00111011 ;

60 00111100 <

61 00111101 =

62 00111110 >

63 00111111 ?

64 01000000 @

65 01000001 A

66 01000010 B

Dec. Unicode Charac.

0x30 0x0030 0

0x31 0x0031 1

0x32 0x0032 2

0x33 0x0033 3

0x34 0x0034 4

0x35 0x0035 5

0x36 0x0036 6

0x37 0x0037 7

0x38 0x0038 8

0x39 0x0039 9

0x3A 0x003A :

0x3B 0x003B ;

0x3C 0x003C <

0x3D 0x003D =

0x3E 0x003E >

0x3F 0x003F ?

0x40 0x0040 @

0x41 0x0041 A

0x42 0x0042 B

ASCII7 bits long

Unicode16 bits long

Partial listings only!

CENG 230 - Spring 2015 Sinan Kalkan 49

Page 50: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

CENG 230 - Spring 2015 Sinan Kalkan 50

Page 51: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Computer organization

CENG 230 - Spring 2015 Sinan Kalkan 51

Page 52: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Computer Organization

Logical organization of computer

CPUInput Output

Memory

SecondaryStorage

ALU

CENG 230 - Spring 2015 Sinan Kalkan 52

Page 53: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Memory and Cache (continued)• RAM (Random Access Memory)

Often called memory, primary memory

• Memory made of addressable “cells”

• Cell size is 8 bits

• Nowadays, it is 32 or 64 bits.

• All memory cells accessed in equal time

• Memory address

• Unsigned binary number N long

• Address space is then 2N cells

CENG 230 - Spring 2015 Sinan Kalkan 53

Page 54: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Programming

CENG 230 - Spring 2015 Sinan Kalkan 54

Page 55: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Program, Programming

PROGRAM

IMPLEMENTED

CENG 230 - Spring 2015 Sinan Kalkan 55

Page 56: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

CENG 230 - Spring 2015 Sinan Kalkan 56

Page 57: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

CENG 230 - Spring 2015 Sinan Kalkan 57

Page 58: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

How are languages implementedC

OM

PIL

ATI

VE

AP

PR

OA

CH

CENG 230 - Spring 2015 Sinan Kalkan 58

Page 59: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

C languagedevelopment environment

CENG 230 - Spring 2015 Sinan Kalkan 59

Page 60: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Sinan Kalkan

The Translation/Loading/Execution Process

60

Page 61: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

CENG 230 - Spring 2015 Sinan Kalkan 61

Page 62: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Bugs, Errors

• Syntax ErrorsArea = 3.1415 * R * R

Area = 3.1415 x R x R

• Run-time Errors

CENG 230 - Spring 2015 Sinan Kalkan 62

Page 63: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

Bugs, Errors

• Logical Errors

• Design Errors

CENG 230 - Spring 2015 Sinan Kalkan 63

Page 64: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

C

CENG 230 - Spring 2015 Sinan Kalkan 64

Page 65: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

History of C• C– Developed by Denis M. Ritchie at AT&T Bell Labs in1972 as a systems programming language– Used to develop UNIX– Used to write modern operating systems– Hardware independent (portable)

• Standardization– Many slight variations of C existed, and were incompatible– Committee formed to create a "unambiguous, machineindependent“ definition– Standard created in 1989, updated in 1999

CENG 230 - Spring 2015 Sinan Kalkan 65

Page 66: CENG 230 Introduction to C Programming - KOVANsinan/ceng230/week1.pdf · CENG 230 Introduction to C Programming Week 1 –Overview and introduction Sinan Kalkan Some slides/content

CENG 230 - Spring 2015 Sinan Kalkan 66