introduction to c.pptx

Upload: john-paul-santos

Post on 01-Jun-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/9/2019 Introduction to C.pptx

    1/16

    Introduction to CPREPARED BY: JOHN PAUL G. SANTOS

  • 8/9/2019 Introduction to C.pptx

    2/16

    Outline

    Introduction

    Pro r!""in Ste#$

    Co"#onent$ o% Tur&o C

    L!n u! e Ele"ent$ o% CIdenti'er$

    D!t! T(#e$)!ri!&le$ !n Con$t!nt Decl!r!tion

    O#er!tor$Arit*"etic

    Rel!tion!l

    Lo ic!l

  • 8/9/2019 Introduction to C.pptx

    3/16

    +*!t i$ C L!n u! e,

    C i$ ! ener!l- #ur#o$e #ro r!""in l!n u! e *ic* %e!ture$econo"( o% e/#re$$ion0 "odern control 1o !nd d!t! $tructure$!nd ! ric* $et o% o#er!tion$

    H!$ &een c!lled !$ 2$($te" #ro r!""in l!n u! e3

    A $tructured #ro r!""in l!n u! e

  • 8/9/2019 Introduction to C.pptx

    4/16

    Pro r!""in Ste#$

    De'ne t*e Pro&le"

    De$i n t*e Solution4Pro r!"

    Code t*e Pro r!"

    Te$t t*e Pro r!"

    Docu"ent Error

  • 8/9/2019 Introduction to C.pptx

    5/16

    Ter"$

    Inter#reterRe!d$ t*e $ource code o% (our #ro r!" one line !t ! ti"e !nd #er%or"$t*e $#eci'c in$truction$ cont!ined in t*!t line.

    Co"#ilerRe!d$ t*e entire #ro r!" !nd con5ert$ it into o&6ect code 7 t*e %or" t*!tc!n &e directl( e/ecuted &( t*e co"#uter

    Co"#ile Ti"eRe%er$ to t*e e5ent$ t*!t occur durin t*e co"#il!tion #roce$$

    O&6ect CodeA tr!n$l!tion o% t*e #ro r!" $ource code in ! %or" t*!t c!n &e directl(e/ecuted &( t*e co"#uter. It i$ !l$o c!lled t*e &in!r( code !nd "!c*inecode

  • 8/9/2019 Introduction to C.pptx

    6/16

    Pro r!""in Proce$$Source Code

    Co"#iler8Co"#il!tion9

    O&6ect Code

    Lin er 8Lin in 9

    E/ecut!&le Code

    ;! e4Edit t*eSource Code

    Pre-#roce$$in

    Clo$e to !code t*!t c!n&e under$tood

    &( t*e"!c*ine

  • 8/9/2019 Introduction to C.pptx

    7/16

    Pro r!""in Proce$$

    Source Code T*e te/t o% ! #ro r!" t*!t ! u$er c!n re!d< co""onl( t*ou *t !$ !#ro r!"

    Run Ti"eRe%er$ to t*e e5ent$ t*!t occur *ile t*e #ro r!" i$ !ctu!ll(e/ecutin

    Li&r!r( T*e collection o% #re- ritten. S(nt!/ error$ !re detected durinco"#iled ti"e

    Se"!ntic Run Ti"e error$ !re detected durin e/ecution-ti"e

  • 8/9/2019 Introduction to C.pptx

    8/16

    Co"#onent$ o% Tur&o C

    EditorU$ed to cre!te #ro r!" code

    E/tended C L!n u! e T*i$ 5er$ion o% C i$ $i ni'c!ntl( e/tended %ro" =&!$e *o"e=l!n u! e o% Ritc*ie>$ S#eci'c!tion.

    T*e e/ten$ion include$ en*!nce"ent *ic* "! e t*e Tur&o Cco"#!ti&le it* t*e ne #ro#o$ed !nd ANSI St!nd!rd.

    Co"#ilerU$ed to con5ert $ource code into "!c*ine code or &in!r( code.

  • 8/9/2019 Introduction to C.pptx

    9/16

    Co"#onent$ o% Tur&o C

    De&u erU$ed %or te$tin #ro r!" !nd loc!tin #ro r!""in error$

    Run Ti"e en5iron"ent i$ t*e c!#!&ilit( %or runnin #ro r!"$ it*in t*e Tur&o C S($te"

    U$er Inter%!ce T*e 5!riou$ %e!ture$ o% Tur&o C !re inte r!ted into ! $in le #ro r!"

    *ic* !llo $ (ou to $"oot*l( #roceed %ro" $ource to code entr( toco"#il!tion to de&u in to runnin it*out e5er le!5in t*e Tur&o Cen5iron"ent.

  • 8/9/2019 Introduction to C.pptx

    10/16

    L!n u! e Ele"ent$ o% C

    Identi'er$

    ?. N!"e$ t*!t !re u$ed to re%erence 5!ri!&le$0 %unction$0 l!&el$!nd 5!riou$ ot*er u$er de'ned o&6ect< $e@uence o% letter$0di it$ !nd $#eci!l c*!r!cter-0 *ic* i$ c!lled under$core

    . ;u$t con$i$t onl( !l#*!&etic c*!r!cter$0 di it$0 orunder$core$

    . T*e 'r$t c*!r!cter$ o% !n identi'er n!"e !re $i ni'c!nt

    . E/!"#le$: Sn!"e0 $n!"e0 ln!"e0 Ln!"e

    . An identi'er "!( not &e t*e $!"e !$ ! Tur&o C e( ord0 !ndit $*ould not *!5e t*e $!"e n!"e !$ %unction.

  • 8/9/2019 Introduction to C.pptx

    11/16

    D!t! T(#e$

    int 5!ri!&le$A *ole nu"&er con$i$tin o% !n o#tion!l $i n 8F or -9 %ollo ed &( !$e@uence o% di it. It c!nnot cont!in co""!$. )!ri!&le$ o% t*i$ t(#e!re o%ten u$ed %or controllin loo#$ !nd condition!l $t!te"ent

    Type Byte Size MinimumValue

    MaximumValue

    $*ort int - Fint - ? F ?lon int - ? F ?un$i ned int ?

  • 8/9/2019 Introduction to C.pptx

    12/16

  • 8/9/2019 Introduction to C.pptx

    13/16

    )!ri!&le$ !nd Con$t!ntDecl!r!tion$

  • 8/9/2019 Introduction to C.pptx

    14/16

    O#er!tor$

    Arit*"etic

    Command Meaning

    8!$teri$ 9 ;ulti#lic!tion

    4 8$l!$*9 Di5i$ion

    F 8#lu$9 Addition

    - 8"inu$9 Su&tr!ction- 8un!r( "inu$9 Ne !tion

    K 8"odulu$9 ;odulu$ Di5i$ion

    FF 8#lu$ #lu$9 Incre"ent O#er!tor

    - - 8"inu$ "inu$9 Decre"ent O#er!tor

    8 9 #!rent*e$i$ P!rent*ei$

  • 8/9/2019 Introduction to C.pptx

    15/16

    Lo ic!l O#er!tor$

    Command Meaning

    And

    MM Or

    Not

  • 8/9/2019 Introduction to C.pptx

    16/16

    Rel!tion!l O#er!tor$

    Command Meaning Gre!ter T*!n

    Le$$ T*!n

    Q Gre!ter T*!n or E@u!l toQ Le$$ t*!n or e@u!l to

    QQ E@u!l to

    Q Not e@u!l to