Midterm Review CS304 Introduc1on to C Why C? - - PowerPoint PPT Presentation

midterm review
SMART_READER_LITE
LIVE PREVIEW

Midterm Review CS304 Introduc1on to C Why C? - - PowerPoint PPT Presentation

Midterm Review CS304 Introduc1on to C Why C? Difference between Python and C C compiler stages Basic syntax in C Pointers What is


slide-1
SLIDE 1

Midterm ¡Review ¡

CS304 ¡

slide-2
SLIDE 2

Introduc1on ¡to ¡C ¡

  • Why ¡C? ¡
  • Difference ¡between ¡Python ¡and ¡C ¡
  • C ¡compiler ¡stages ¡
  • Basic ¡syntax ¡in ¡C ¡
slide-3
SLIDE 3

Pointers ¡

  • What ¡is ¡a ¡pointer? ¡

– declara@on, ¡&, ¡dereference ¡... ¡

  • Pointer ¡& ¡dynamic ¡memory ¡alloca@on ¡

– Virtual ¡memory ¡

  • Pointer ¡& ¡arrays ¡

– Rela@onship ¡between ¡pointer ¡and ¡array ¡name ¡ – sizeof, ¡strlen... ¡

  • Pointer ¡arithme@c ¡

– *(array_ptr++) ¡and ¡(*array_ptr)++ ¡ ¡ – [] ¡and ¡* ¡ – pointers ¡to ¡arrays ¡and ¡array ¡of ¡pointers ¡

slide-4
SLIDE 4

Pointers ¡

  • Pointer ¡& ¡func@ons ¡

– passing ¡by ¡value ¡& ¡passing ¡by ¡reference ¡ – func@on ¡pointers ¡

  • Pointer ¡& ¡structures ¡
  • Struct ¡declara@on ¡and ¡defini@on ¡

– #define ¡and ¡typedef ¡ – access ¡struct ¡with ¡pointers ¡ – offsetof ¡ ¡

slide-5
SLIDE 5

Introduc1on ¡to ¡Computer ¡Organiza1on ¡

  • Three ¡layers ¡in ¡computer ¡system ¡

– soTware/os/hardware ¡

  • Hardware ¡organiza@on ¡

– Von ¡Neumann ¡Architecture ¡ – virtual ¡memory ¡and ¡cache ¡hierarchy ¡

  • What ¡will ¡happen ¡if ¡we ¡type ¡a ¡linux ¡command ¡

in ¡command ¡line? ¡

slide-6
SLIDE 6

Informa1on ¡Representa1on ¡

  • Number ¡systems ¡

– Decimal, ¡Binary, ¡Hexadecimal, ¡Octal, ¡base-­‑10 ¡

  • Two ¡important ¡limita@ons ¡

– Overflow, ¡accuracy ¡

  • Informa@on ¡storage ¡and ¡byte ¡order ¡

– interpreta@on ¡is ¡important ¡ – word ¡size ¡ – byte ¡ – big ¡endian ¡and ¡li^le ¡endian ¡

slide-7
SLIDE 7

Integers ¡

  • Why ¡low ¡level ¡representa@on? ¡
  • B2U, ¡B2T, ¡B2O, ¡B2S ¡

– range ¡& ¡min, ¡max ¡

  • Signed ¡vs. ¡unsigned ¡
  • Integer ¡opera@ons ¡

– sign ¡extend, ¡trunca@on, ¡addi@on, ¡nega@on, ¡ mul@plica@on, ¡division ¡ – overflow, ¡mul@plica@on ¡by ¡constant, ¡division ¡by ¡power ¡

  • f ¡2, ¡rounding ¡

– shiT ¡and ¡bit ¡opera@ons ¡

slide-8
SLIDE 8

Floa1ng ¡Point ¡Numbers ¡

  • Binary ¡floa@ng ¡point ¡ ¡
  • IEEE-­‑754 ¡format ¡

– single ¡precision: ¡ ¡

  • 1[31]-­‑sign, ¡8[30-­‑23]-­‑exponent, ¡23[22-­‑0]-­‑frac@on, ¡127-­‑bias ¡ ¡
  • Normalized ¡& ¡special ¡values ¡

– 0, ¡subnormal ¡(de-­‑normalized), ¡+/-­‑infinity, ¡NaN ¡ – bias, ¡hidden ¡bit ¡

  • Range ¡and ¡precision ¡
  • Rounding, ¡cas@ng, ¡special ¡opera@ons ¡
slide-9
SLIDE 9

Exam ¡format ¡

  • True ¡or ¡false ¡

– foo@cs ¡is ¡a ¡valid ¡variable ¡name ¡

  • Mul@ple ¡choice ¡

– code ¡reading ¡and ¡basic ¡concepts ¡ – compiler ¡stages ¡

  • Short ¡answer ¡

– code ¡reading/wri@ng ¡ – integer/ ¡float ¡point ¡number ¡calcula@on ¡ – IEEE754 ¡format ¡

  • Code ¡evalua@on ¡

– code ¡reading, ¡explain ¡and ¡fill ¡in ¡blanks ¡ – find ¡bugs; ¡string ¡opera@on; ¡linked ¡list ¡opera@on ¡

slide-10
SLIDE 10

Sugges1ons ¡

  • slides! ¡
  • textbook! ¡
  • Lab1 ¡& ¡HW1! ¡
  • “reading ¡assignments” ¡and ¡“self-­‑study” ¡contents ¡
  • n ¡our ¡website ¡
  • Prac@ce ¡problems ¡on ¡our ¡website ¡