+ All Categories
Home > Documents > Chapter 1 Intro to C++

Chapter 1 Intro to C++

Date post: 01-Jun-2018
Category:
Upload: harwindran-ganison
View: 225 times
Download: 0 times
Share this document with a friend

of 13

Transcript
  • 8/9/2019 Chapter 1 Intro to C++

    1/13

    FP 201 Programming

    FundamentalsCHAPTER 1 : INTRODUCTION TO

    C++ PROGRAMMING

    1.1 Introducing the C++ PrograingEn!ironent

  • 8/9/2019 Chapter 1 Intro to C++

    2/13

    1.1.1 Hi"tor# o$ C++1%&'Denni" Ritchie de!e(o)ed the *a"i" o$ C

    eature" : arra#" and )ointer", ca)a*(e o$)orta*i(it#.

    1%-

    /0arne trou"tru) 2 /e(( 3a*" 4 *egande!e(o)ent o$ C++

  • 8/9/2019 Chapter 1 Intro to C++

    3/13

    1.1.1 Hi"tor# o$ C++ 2cont.41%-5In Octo*er, 6r"t coercia( re(ea"e o$ C++

    a))eared 7ith the (aunch o$ 8The C++Prograing 3anguage9 *# /0arne trou"tru).

    1%-5+C++ (anguage re6ned unti( *ecae a (anguage

    7ith o7n )er"ona(it#

    C++ (i!ed a great e)an"ion in it" u"e" andtoda# i" "ti(( the )re$erred (anguage to de!e(o))ro$e""iona( a))(ication" on a(( )(at$or.

  • 8/9/2019 Chapter 1 Intro to C++

    4/13

    1"t

    A""ignent;hat are the di

  • 8/9/2019 Chapter 1 Intro to C++

    5/13

    1.1.> C++ Progra tructure

    preprocessor directives

    main function heading?

    declarations

    executable statements

    @

    inc(ude

    Bio"treaint ain2 4

    ?

    "tateent2"4

    @

  • 8/9/2019 Chapter 1 Intro to C++

    6/13

    1.1.' C++ Prograing

    De!e(o)ent Proce""1. Identi$# the )ro*(e

    >. Ana(#Fe the )rogra

    '. Ana(#Fe the data

    . Decide IO $or the entire )rogra

    5. Choo"e "uita*(e a(gorithic a))roach

    . Tran"(ation o$ the a(gorith Coding

    &. Co)i(e and (ining

    -. Te"t the )rogra

    %. JDe*ug i$ nece""ar#

    2 7hen )rogra doe" not generate de"ired re"u(t" 4

    C(ic on the STARto!ie7

  • 8/9/2019 Chapter 1 Intro to C++

    7/13

    1.1. Integrated De!e(o)ent

    En!ironent 2IDE4De6nition : A "o$t7are a))(ication that )ro!ide"

    co)rehen"i!e $aci(itie" to co)uter )rograer"$or "o$t7are de!e(o)ent.

    An IDE con"i"t" o$ :ource editor

    Co)i(er and or Inter)reter

    /ui(d autoation too("

    De*ugger

    Ea)(e" o$ IDE : Ec(i)"e, Micro"o$t Ki"ua( tudio,

    ;inDe!, LCode, /(ood"hed De! C++.

  • 8/9/2019 Chapter 1 Intro to C++

    8/13

    FP 201 ProgrammingFundamentals

    CHAPTER 1 : INTRODUCTION TO

    C++ PROGRAMMING

    1.> Identi$#ing the Co)i(ing De*uggingProce"", Error" in Prograing

  • 8/9/2019 Chapter 1 Intro to C++

    9/13

    1.>.1 Co)i(ing Proce""CompilerTran"(ate the 7ho(e )rogra at one tie.

    Tran"(ate" the "ource code, $or ea)(e C(anguage to achine (anguage.

    # include

    main( )

    {

    int x, y, z, sum;

    double avg;

    cout > x >>y>>z;

    sum ! x y z;

    avg ! sum 3;

    cout

  • 8/9/2019 Chapter 1 Intro to C++

    10/13

    1.>.> Error" in

    Prograing Compile-time errorsOccur" 7hen the ru(e" o$ )rograing

    (anguage are not a))(ied

    Correction i" done during the )rogra coding

    The *ug can *e traced during the co)i(ation

    A("o no7n a" syntax error

    Mu"t *e corrected *e$ore eecuting and te"tingthe )rogra

  • 8/9/2019 Chapter 1 Intro to C++

    11/13

    1.>.> Error" in Prograing 2cont.4 Run-time errorsCannot *e traced *# co)i(er

    Occur 7hi(e )rogra run", 7hen the )rograatte)t" an o)eration that i" i)o""i*(e tocarr# out.

    A("o no7n a" logic error

    Ea)(e di!i"ion *# Fero

  • 8/9/2019 Chapter 1 Intro to C++

    12/13

    1.>.> Error" in Prograing 2cont.4Logical errors An error cau"ed *# $o((o7ing an incorrect

    algoritm

    Ker# dicu(t to detect it doe" not cau"e runtie error and doe" not di")(a# e""ageerror"

    The on(# "ign o$ (ogic error incorrect )rogra

    out)ut

    Can *e detected *# te"ting the )rograthorough(#, co)aring it" out)ut to ca(cu(atedre"u(t"

    To )re!ent care$u((# de" checing the

  • 8/9/2019 Chapter 1 Intro to C++

    13/13

    La! 1De*ugging)rogra"7ith co)i(etie, runtie and

    (ogica( error".


Recommended