39
BBS 514 YAPISAL PROGRAMLAMA (STRUCTURED PROGRAMMING) BBS 514 Yapısal Programlama (Structured Programming) 1

BBS#514 YAPISAL#PROGRAMLAMA …burcucan/BBS514-Introduction.pdf · BBS’514’?Yapısal Programlama(Structured’Programming) 32 edu com org net-educational institution-commercial

  • Upload
    others

  • View
    14

  • Download
    0

Embed Size (px)

Citation preview

BBS  514

YAPISAL  PROGRAMLAMA(STRUCTURED PROGRAMMING)

BBS  514  -­‐ Yapısal Programlama (Structured  Programming)

1

Course  Information

¤ Instructor:              Name:  Assist.  Prof.  Burcu  CanOffice:  Dept.  Of  Computer Engineering,  Room 217Tel:  297-­‐7500Email:    [email protected]  Web  Page:  http://web.cs.hacettepe.edu.tr/~burcucan/BBS514

Text Book: Programming  in  ANSI  C,  Ram  Kumar  and  Rakesh  Agrawal,  West  Publishing  Company,  1992.  

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

2

Course  Organization (Exams)

¨ One  midterm,  one  final  exam.  ¨ Dates  and  times  will  be  announced  on  the  web  and  in  class.  ¨ Programming  assignments¨ Grading  policy  on  course  web  page

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

3

Course  Organization (Syllabus)

BBS  514  -­‐ Yapısal Programlama (Structured  Programming)

4

Grading

¨ 1  Midterm:  %30¨ Final:  %40¨ 3  Assignments:  %30

Assignments

¨ 1st Assignment:  18  October¨ 2nd Assignment:  15  November¨ 3rd Assignment:  13  December

Computers

BBS  514  -­‐ Yapısal Programlama (Structured  Programming)

7

Hardware  &  Software

¨ The  set  of  instructions  that  controls  computers  are  known  as  computer  programs  (software).¤ a  program is  a  series  of  instructions

¨ The  physical  structure  of  the  computer  is  called  as  hardware.¤ the  physical,  tangible  parts  of  a  computer¤ keyboard,  monitor,  disks,  wires,  chips,  etc.

¨ A  computer  requires  both  hardware  and  software

¨ Each  is  essentially  useless  without  the  otherBBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

8

Hardware

¨ A  modern  computer  consists  of    five  main  components  and  they  are  all  parts  of  computer  hardware:¤ Memory¤ Central  Processing  Unit  (CPU)¤ Input  Devices¤ Output  Devices¤ Secondary  Storage

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

9

CPU  and  Main  Memory

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

10

CentralProcessing

Unit

MainMemory

Chip that executes program commands

Intel Pentium 4Sun ultraSPARC III

Primary storage area for programs and data

that are in active use

Synonymous with RAM

Secondary  Memory  Devices

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

11

CentralProcessing

Unit

MainMemory

USB Disk

Hard Disk

Secondary memorydevices providelong-term storage

Information is movedbetween main memoryand secondary memoryas needed

Hard disksFloppy disksZIP disksWritable CDsWritable DVDsTapes

Input  /  Output  Devices

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

12

CentralProcessing

Unit

MainMemory

USB Disk

Hard Disk

Monitor

Keyboard

I/O devices facilitateuser interaction

Monitor screenKeyboardMouseJoystickBar code scannerTouch screen

Computer  Organization  (Memory)

Memory¨ Store  information  (data  +  instructions)¨ A  sequence  of  memory  cells.

¤ a  byte  is  8  bits¤ a  bit  is  smallest  unit  (0  or  1)

¨ Stored  information  in  memory  is  volatile.¨ Size  of  a  memory of  a  typical PC  system:  8GB,  16GB,  etc.  

¤ KB,  MB,  GB

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

13

Computer  Organization  (CPU)

CPU  (Central  Processing  Unit)¨ Process  and  manipulate  information  stored  in  memory.¨ It  can  be  divided  into  two  units:    CU  (Control  Unit)  and  ALU  (Arithmetic  Logic  Unit)

¨ CU  coordinates  activities  of  the  computer  and  controls  other  devices  of  computer.

¨ ALU  processes  arithmetic  and  logical  instructions.

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

14

Computer  Organization  (Input  and  Output  Devices)

Input  and  Output  Devices¨ Provide  the  interface  between  the  user  and  the  computer.¨ Input  devices  are  used  to  enter  instructions  or  data  by  the  user.¨ Output  devices  are  used  to  give  results  of  computations.¨ Input  Devices:  keyboard,  mouse¨ Output  Devices:  monitor,  printer

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

15

Computer  Organization  (Secondary  Storage)

Secondary  Storage¨ Computers  have  limited  main  memory  and  information  stored  in  main  memory  is  volatile.  

i.e.  when  a  computer  is  switched  off,  information  in  its  main  memory  disappears.¨ There  are  additional  data  storage  unit,  called  secondary  storage  units.¨ Data  stored  in  these  secondary  storage  units  are  permanent,  i.e.  data  does  not  disappear  

when  you  switch  off  the  computer.¨ Some  secondary  storage  u  nits:  

¤ Hard  Disks¤ Tape  Drive¤ Optic  Disk  (CD  Drive,  DVD  Drive)¤ Flash  Disk  (USB  Disks)

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

16

A  Computer  Specification

¨ Consider  the  following  specification  for  a  personal  computer:  

¤ 2.8  GHz  Pentium  4  Processor¤ 8  GB  RAM¤ 80  GB  Hard  Disk¤ 48x  CD-­‐RW  /  DVD-­‐ROM  Combo  Drive  ¤ 17”  Video  Display  with  1280  x  1024  resolution¤ 56  Kb/s  Modem

¨ What  does  it  all  mean?BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

17

Memory

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

18

Main memory is divided into many memory locations (or cells)

927892799280928192829283928492859286

Each memory cell has a numeric address, which uniquely identifies it

Storing  Information

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

19

927892799280928192829283928492859286

Large values arestored in consecutivememory locations

10011010Each memory cell stores a set number of bits (usually 8 bits, or one byte)

Storage  Capacity

¨ Every  memory  device  has  a  storage  capacity,  indicating  the  number  of  bytes  it  can  hold

¨ Capacities  are  expressed  in  various  units:

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

20

KB 210 = 1024MB 220 (over 1 million)GB 230 (over 1 billion)TB 240 (over 1 trillion)

Unit Symbol Number of Bytes

kilobytemegabytegigabyteterabyte

Memory

¨ The  terms  direct  access and  random  access often  are  used  interchangeably

¨ Main  memory  and  disks  are  direct  access devices  -­‐information  can  be  reached  directly

¨ A  magnetic  tape  is  a  sequential  access device  since  its  data  is  arranged  in  a  linear  order    -­‐ you  must  get  by  the  intervening  data  in  order  to  access  other  information

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

21

RAM  vs.  ROM

¨ RAM -­‐ Random  Access  Memory  (direct  access)

¨ ROM -­‐ Read-­‐Only  Memory

¨ The  terms  RAM  and  main  memory  are  basically  interchangeable

¨ Both  RAM  and  ROM  are  random  (direct)  access  devices!

¨ RAM  probably  should  be  called  Read-­‐Write  Memory

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

22

Compact  Discs

¨ A  CD-­‐ROM  is  portable  read-­‐only  memory

¨ A  microscopic  pit  on  a  CD  represents  a  binary  1  and  a  smooth  area  represents  a  binary  0

¨ A  low-­‐intensity  laser  reflects  strongly  from  a  smooth  area  and  weakly  from  a  pit

¨ A  CD-­‐Recordable  (CD-­‐R)  drive  can  be  used  to  write  information  to  a  CD  once

¨ A  CD-­‐Rewritable  (CD-­‐RW)  can  be  erased  and  reused

¨ The  speed  of  a  CD  drive  indicates  how  fast  (max)  it  can  read  and  write  information  to  a  CD

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

23

DVDs

¨ A  DVD  is  the  same  size  as  a  CD,  but  can  store  much  more  information

¨ The  format  of  a  DVD  stores  more  bits  per  square  inch

¨ A  CD  can  store  650  MB,  while  a  standard  DVD  can  store  4.7  GB¤ A  double  sided  DVD  can  store  9.4  GB

¤ Other  advanced  techniques  can  bring  the  capacity  up  to  17.0  GB

¨ Like  CDs,  there  are  DVD-­‐R  and  DVD-­‐RW  discs

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

24

Monitor

¨ The  size  of  a  monitor  (17")  is  measured  diagonally,  like  a  television  screen

¨ A  monitor  has  a  certain  maximum  resolution ,  indicating  the  number  of  picture  elements,  called  pixels,  that  it  can  display  (such  as  1280  by  1024)

¨ High  resolution  (more  pixels)  produces  sharper  pictures

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

25

Networks

¨ A  network is  two  or  more  computers  that  are  connected  so  that  data  and  resources  can  be  shared

¨ Most  computers  are  connected  to  some  kind  of  network

¨ Each  computer  has  its  own  network  address,  which  uniquely  identifies  it  among  the  others

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

26

Local-­‐Area  Networks

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

27

LAN

A Local-Area Network(LAN) covers a smalldistance and a smallnumber of computers

A LAN often connects the machinesin a single room or building

Wide-­‐Area  Networks

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

28

LAN

A Wide-Area Network (WAN)connects two or more LANs,often over long distances

A LAN usually is ownedby one organization, buta WAN often connectsgroups in different countries

LAN

The  Internet

¨ The  Internet is  a  WAN  which  spans  the  entire  planet

¨ The  word  Internet  comes  from  the  term  internetworking

¨ It  started  as  a  United  States  government  project,  sponsored  by  the  Advanced  Research  Projects  Agency  (ARPA)  -­‐ originally  it  was  called  the  ARPANET

¨ The  Internet  grew  quickly  throughout  the  1980s  and  90s

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

29

TCP/IP

¨ A  protocol  is  a  set  of  rules  that  determine  how  things  communicate  with  each  other

¨ The  software  which  manages  Internet  communication  follows  a  suite  of  protocols  called  TCP/IP

¨ The  Internet  Protocol (IP)  determines  the  format  of  the  information  as  it  is  transferred

¨ The  Transmission  Control  Protocol (TCP)  dictates  how  messages  are  reassembled  and  handles  lost  information

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

30

IP  and  Internet  Addresses

¨ Each  computer  on  the  Internet  has  a  unique  IP  address,  such  as:  204.192.116.2

¨ Most  computers  also  have  a  unique  Internet  name,  which  also  is  referred  to  as  an  Internet  address:

spencer.villanova.edu

kant.gestalt-llc.com

¨ The  first  part  indicates  a  particular  computer  (spencer)

¨ The  rest  is  the  domain  name,  indicating  the  organization  (villanova.edu)

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

31

Domain  Names

¨ The  last  part  of  a  domain  name,  called  a  top-­‐level  domain  (TLD),  indicates  the  type  of  organization:

BBS  514  -­‐ Yapısal Programlama (Structured  Programming)

32

educomorgnet

- educational institution- commercial entity- non-profit organization- network-based organization

Sometimes the suffixindicates the country: New TLDs have

recently been added:

biz, info, tv, name

ukaucase

- United Kingdom- Australia- Canada- Sweden

Domain  Names

¨ A  domain  name  can  have  several  parts

¨ Unique  domain  names  mean  that  multiple  sites  can  have  individual  computers  with  the  same  local  name

¨ When  used,  an  Internet  address  is  translated  to  an  IP  address  by  software  called  the  Domain  Name  System (DNS)

¨ There  is  no one-­‐to-­‐one  correspondence  between  the  sections  of  an  IP  address  and  the  sections  of  an  Internet  address

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

33

The  World  Wide  Web

¨ The  World  Wide  Web allows  many  different  types  of  information  to  be  accessed  using  a  common  interface

¨ A  browser is  a  program  which  accesses  and  presents  information

¤ text,  graphics,  video,  sound,  audio,  executable  programs

¨ A  Web  document  usually  contains  links to  other  Web  documents,  creating  a  hypermedia environment

¨ The  term  Web  comes  from  the  fact  that  information  is  not  organized  in  a  linear  fashion

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

34

The  World  Wide  Web

¨ Web  documents  are  often  defined  using  the  HyperText Markup  Language (HTML)

¨ Information  on  the  Web  is  found  using  a  Uniform  Resource  Locator(URL):

http://www.lycos.com

http://www.villanova.edu/webinfo/domains.html

ftp://java.sun.com/applets/animation.zip

¨ A  URL  indicates  a  protocol  (http),  a  domain,  and  possibly  specific  documents BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

35

Software

¨ The  set  of  instructions  controls  computers  are  known  as  computer  programs  (software).

¨ a  software is  a  series  of  instructions

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

36

Software  Types¨ Operating  System

¤ Controls  all  machine  activities¤ Provides  the  user  interface  to  the  computer.¤ Manages  resources  such  as  CPU  and  memory¤ Windows,  Unix,  MacOS,  Android

¨ Application  Program¤ generic  form  for  all  other  kind  of  software¤ games,  word  processors,  compilers

¨ Most  operating  systems  and  application  programs  have  a  graphical  user  interface (GUI)

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

37

File/Directory

¨ File contains  a  document  and  Directory contains  files  or  other  directories.¨ You  will  be  able  to  create  files  and  directories¨ a  file  can  contain  different  types  of  information,  and  normally  the  extension  of  that  file  reflects  the  content  of  that  file.¤ .doc :     a  word  document¤ .c :    A  C  program  file¤ .exe :    Executable file¤ .java : a  java  program¤ .class :   a  class  file¤ .html :   a  hypertext  file  used  to  represent  a    web  page

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

38

Software

¨ In this course,  we will learn how  to write computer programs using C  programming language.

¨ Before,  we start  to learn C  programming language we will talk  about:¤ ALGORITHMS:  a  sequence of  instructions to solve a  problem

BBS  514  -­‐ Yapısal  Programlama  (Structured  Programming)

39